Exemple #1
0
        public override void onTransaction(TransactionMessage message)
        {
            Logger.getInstance().log("Processing transaction", LOGGING_NAME, Logger.Level.INFO);

            coordinator.setNodeCount(TcpSender.getInstance().getServerNodesCount());
            SqlParser parser = new SqlParserImpl();

            if(!parser.parse(message.QueryString))
            {
            Logger.getInstance().log("Unparsable query - send back error and end transaction", LOGGING_NAME, Logger.Level.INFO);

            TcpSender.getInstance().sendToNode(new RBD.Msg.Client.ErrorMessage("Bad query"), message.Sender);
            coordinator.endTransaction();
            return;
            }

            coordinator.setQueryString( parser.getQueryString() );
            coordinator.TableName = parser.getTableName();

            if(parser.getOperationType().Equals(SqlOperationType.SELECT))
            {
            Logger.getInstance().log("Select query detected", LOGGING_NAME, Logger.Level.INFO);
            coordinator.processSelect();
            }
            else
            {
            CanCommitMessage msg = new CanCommitMessage();
            msg.TableName = parser.getTableName();
            msg.QueryString = parser.getQueryString();
            msg.TableVersion = coordinator.DatabaseState.getTableVersion(msg.TableName);
            if(parser.getOperationType().Equals(SqlOperationType.CREATE)) {
                msg.IsCreate = true;
            }
            else {
                msg.IsCreate = false;
            }

            Logger.getInstance().log("Changing state to waiting", LOGGING_NAME, Logger.Level.INFO);

            coordinator.broadcastMessage(msg);
            coordinator.changeState(new WaitingState());
            }
        }
Exemple #2
0
        //throws InterruptedException
        public void processTransactionMessage(TransactionMessage msg)
        {
            String transactionId = Util.Util.generateGUID();

            Logger.getInstance().log(
                    "Creating coordinator with tid - " + transactionId + " : " + msg.toString(),
                    LOGGING_NAME,
                    Logger.Level.INFO);

            // create COORDINATOR
            Coordinator coor = new CoordinatorImpl();
            coordinators[transactionId] = coor;
            coor.setTransactionId(transactionId);
            coor.setClientAddress(msg.getSender());
            coor.setDatabaseState(DatabaseStateImpl.getInstance());
            coor.setConnector(DbConnectorImpl.getInstance());
            coor.addEndTransactionListener(this);

            // give him the message
            coor.processMessage(msg);
        }
Exemple #3
0
 /**
  */
 public virtual void onTransaction(TransactionMessage message)
 {
     Logger.getInstance().log("Nie oczekiwano wiadomosci: TransactionMessage", LOGGER_NAME, Logger.Level.WARNING);
 }