Пример #1
0
        /// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            // TODO: Replace the following sample code with your own logic
            //       or remove this RunAsync override if it's not needed in your service.

            long iterations = 0;

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                m_TripleStoreMemoryCloudClient.Ping();

                var messageResponse = m_TripleStoreMemoryCloudClient.HelloMessage(new HelloNessageRequestWriter($"Hello from GE/SF Remoting Client"));

                Log.WriteLine($"Working");

                var storeTripleRequest =
                    new StoreTripleRequestWriter()
                {
                    Subject   = @"GraphEngine",
                    Predicate = @"IsA",
                    Object    = @"GraphDataManagementSystem"
                };

                ServiceEventSource.Current.ServiceMessage(this.Context, "Working-{0}", ++iterations);

                //var tripleResponse = m_TripleStoreMemoryCloudClient.StoreTriple(storeTripleRequest);

                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false);
            }
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            LoggingLevel = Trinity.Diagnostics.LogLevel.Debug;
            client       = new TrinityClient("localhost:5304");

            client.RegisterCommunicationModule <TripleStoreServiceModule>();
            //client.RegisterCommunicationModule<TrinityClientModule>();
            client.Start();

            var clientModule = client.GetCommunicationModule <TrinityClientModule>();

            var clientModuleInstance = clientModule.Clients;

            var tctm = Global.CloudStorage.GetCommunicationModule <TripleStoreServiceModule>();

            while (true)
            {
                try
                {
                    var tripleStatement = new TripleStatement()
                    {
                        BaseUri   = @"http:\\www.inknowworks.semanticweb\ontology",
                        Subject   = "GraphEngine",
                        Predicate = "IsAwesome",
                        Object    = "DataManagementSystem"
                    };

                    using (var message = new StoreTripleRequestWriter(tripleStatement))
                        using (var rsp = client.StoreTriple(message))
                        {
                            if (rsp != null)
                            {
                                Console.WriteLine($"Server responses with rsp code={rsp.Triple.BaseUri}");
                            }
                        }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                await Task.Delay(1000);
            }
        }
            public unsafe static StoreTripleResponseReader StoreTriple(this Trinity.Storage.IMessagePassingEndpoint storage, StoreTripleRequestWriter msg)
            {
                byte *bufferPtr = msg.buffer;

                *(int *)(bufferPtr) = msg.Length + TrinityProtocol.TrinityMsgHeader;
                *(TrinityMessageType *)(bufferPtr + TrinityProtocol.MsgTypeOffset) = TrinityMessageType.SYNC_WITH_RSP;
                *(ushort *)(bufferPtr + TrinityProtocol.MsgIdOffset) = (ushort)global::InKnowWorks.TripleStoreMemoryCloud.Protocols.TSL.TSL.CommunicationModule.TripleStoreMemoryCloudServiceModule.SynReqRspMessageType.StoreTriple;
                TrinityResponse response;

                storage.SendMessage <TripleStoreMemoryCloudServiceModuleBase>(bufferPtr, msg.Length + TrinityProtocol.MsgHeader, out response);
                return(new StoreTripleResponseReader(response.Buffer, response.Offset));
            }