예제 #1
0
파일: InitState.cs 프로젝트: Mofsy/sr-rbd
        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());
            }
        }
예제 #2
0
파일: Dispatcher.cs 프로젝트: Mofsy/sr-rbd
        //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);
        }
예제 #3
0
 /**
  */
 public virtual void onTransaction(TransactionMessage message)
 {
     Logger.getInstance().log("Nie oczekiwano wiadomosci: TransactionMessage", LOGGER_NAME, Logger.Level.WARNING);
 }