Esempio n. 1
0
        private Response HandleTransactionMessage(Message txnMessage)
        {
            bool handledOk = false;

            switch (txnMessage.Header.ToLowerInvariant())
            {
            case "txn":
                var updateTransaction = ClusterUpdateTransaction.FromMessage(txnMessage);
                handledOk = _requestHandler.ProcessSlaveTransaction(updateTransaction);
                break;

            case "spu":
                var sparqlTransaction = ClusterSparqlTransaction.FromMessage(txnMessage);
                handledOk = _requestHandler.ProcessSlaveTransaction(sparqlTransaction);
                break;

            case "+store":
                handledOk = _requestHandler.CreateStore(txnMessage.Args);
                break;

            case "-store":
                handledOk = _requestHandler.DeleteStore(txnMessage.Args);
                break;
            }
            return(new Response(handledOk ? Message.ACK : Message.NAK));
        }
Esempio n. 2
0
        /// <summary>
        /// Handler function for messages that can be received by the slave
        /// through the initial sync connection with the master
        /// </summary>
        /// <param name="msg">The message received</param>
        /// <returns>The response to send to the message</returns>
        private Response HandleSyncMessage(Message msg)
        {
            bool handledOk = false;

            switch (msg.Header.ToLowerInvariant())
            {
            case "txn":
                var txn = ClusterUpdateTransaction.FromMessage(msg);
                handledOk = _requestHandler.ProcessSyncTransaction(txn);
                break;

            case "+store":
                handledOk = _requestHandler.CreateStore(msg.Args);
                break;

            case "-store":
                handledOk = _requestHandler.DeleteStore(msg.Args);
                break;

            case "endsync":
                var syncStatus = msg.Args.Split(' ')[0];
                _requestHandler.SlaveSyncCompleted(syncStatus);
                handledOk = true;
                break;
            }
            if (handledOk)
            {
                return(new Response(Message.ACK));
            }
            return(new Response(Message.NAK, true));
        }