public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
             processProxy = new ProcessProxy();
             var pofContext = new PofContext().With(x => {
            x.MergeContext(new DspPofContext());
            x.MergeContext(new TrinketsApiPofContext());
            x.MergeContext(new TrinketsImplPofContext());
             });
             ICollectionFactory collectionFactory = new CollectionFactory();
             IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory);
             IThreadingProxy threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
             var dnsProxy = new DnsProxy();
             INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));
             pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             ProxyGenerator proxyGenerator = new ProxyGenerator();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

             // construct libdsp local service node
             ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
             ServiceClient localServiceClient = serviceClientFactory.Construct(clusteringConfiguration);
             keepaliveObjects.Add(localServiceClient);

             temporaryFileService = localServiceClient.GetService<TemporaryFileService>();

             var processInjector = new ProcessInjectorImpl();
             ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);
             processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
             IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
             BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();
             trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
             trinketDtpServerFactory = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
        public PofDispatcherIT()
        {
            IThreadingFactory       threadingFactory       = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory = new SynchronizationFactory();
            IThreadingProxy         threadingProxy         = new ThreadingProxy(threadingFactory, synchronizationFactory);

            testObj = new PofDispatcherImpl(threadingProxy, pofStreamReader);
        }
 public ThumbnailGenerationEgg()
 {
     collectionFactory = new CollectionFactory();
      var streamFactory = new StreamFactory();
      var processProxy = new ProcessProxy();
      threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
      pofContext = new PofContext().With(x => {
     x.MergeContext(new ManagementPofContext());
     x.MergeContext(new ThumbnailGeneratorApiPofContext());
      });
      pofSerializer = new PofSerializer(pofContext);
      networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(new DnsProxy()), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(new DnsProxy()));
      thumbnailGeneratorService = new ThumbnailGeneratorServiceImpl();
 }
        public ThumbnailGenerationEgg()
        {
            collectionFactory = new CollectionFactory();
            var streamFactory = new StreamFactory();
            var processProxy  = new ProcessProxy();

            threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
            pofContext     = new PofContext().With(x => {
                x.MergeContext(new ManagementPofContext());
                x.MergeContext(new ThumbnailGeneratorApiPofContext());
            });
            pofSerializer             = new PofSerializer(pofContext);
            networkingProxy           = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(new DnsProxy()), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(new DnsProxy()));
            thumbnailGeneratorService = new ThumbnailGeneratorServiceImpl();
        }
        private static void Main(string[] args)
        {
            //var network = new LocalCourierNetwork(dropRate: 0.1);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            var                        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IThreadingFactory          threadingFactory          = new ThreadingFactory();
            ISynchronizationFactory    synchronizationFactory    = new SynchronizationFactory();
            IThreadingProxy            threadingProxy            = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            var                        network = new UdpCourierNetwork(networkingProxy, new UdpCourierNetworkConfiguration(50555));
            var                        tasks   = Util.Generate(4, i => new Thread(() => EntryPoint(i, network)).With(t => t.Start()));

            tasks.ForEach(t => t.Join());
        }
Exemple #6
0
        public static int Main()
        {
            ICollectionFactory      collectionFactory            = new CollectionFactory();
            ProxyGenerator          proxyGenerator               = new ProxyGenerator();
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            IPofContext                pofContext                = new ClientPofContext();
            IPofSerializer             pofSerializer             = new PofSerializer(pofContext);
            PofStreamsFactory          pofStreamsFactory         = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            var serviceConfiguration = new ClientClusteringConfiguration();
            var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
            var localEndPoint        = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
            var reconnectAttempts    = 10;
            var reconnectDelay       = 1000;
            var serviceClient        = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);

            if (serviceClient == null)
            {
                Console.Error.WriteLine("Failed to connect to endpoint.");
                return(1);
            }
            else
            {
                var dispatcher = new DispatcherCommand("registered commands");
                dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
//            dispatcher.RegisterCommand(new ModCommand(serviceClient));
                dispatcher.RegisterCommand(new ExitCommand());
                dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

                var repl = new DargonREPL(dispatcher);
                repl.Run();
                return(0);
            }
        }
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
            processProxy  = new ProcessProxy();
            var pofContext = new PofContext().With(x => {
                x.MergeContext(new DspPofContext());
                x.MergeContext(new TrinketsApiPofContext());
                x.MergeContext(new TrinketsImplPofContext());
            });
            ICollectionFactory collectionFactory = new CollectionFactory();
            IFileSystemProxy   fileSystemProxy   = new FileSystemProxy(streamFactory);
            IThreadingProxy    threadingProxy    = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
            var dnsProxy = new DnsProxy();
            INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));

            pofSerializer = new PofSerializer(pofContext);
            PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            ProxyGenerator proxyGenerator       = new ProxyGenerator();
            var            serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

            // construct libdsp local service node
            ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
            ServiceClient           localServiceClient      = serviceClientFactory.Construct(clusteringConfiguration);

            keepaliveObjects.Add(localServiceClient);

            temporaryFileService = localServiceClient.GetService <TemporaryFileService>();

            var processInjector = new ProcessInjectorImpl();
            ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);

            processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
            IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
            BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();

            trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
            trinketDtpServerFactory  = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
        public static int Main()
        {
            ICollectionFactory collectionFactory = new CollectionFactory();
             ProxyGenerator proxyGenerator = new ProxyGenerator();
             IThreadingFactory threadingFactory = new ThreadingFactory();
             ISynchronizationFactory synchronizationFactory = new SynchronizationFactory();
             IThreadingProxy threadingProxy = new ThreadingProxy(threadingFactory, synchronizationFactory);
             IDnsProxy dnsProxy = new DnsProxy();
             ITcpEndPointFactory tcpEndPointFactory = new TcpEndPointFactory(dnsProxy);
             IStreamFactory streamFactory = new StreamFactory();
             INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
             ISocketFactory socketFactory = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
             INetworkingProxy networkingProxy = new NetworkingProxy(socketFactory, tcpEndPointFactory);
             IPofContext pofContext = new ClientPofContext();
             IPofSerializer pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             var serviceConfiguration = new ClientClusteringConfiguration();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);
             var localEndPoint = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port);
             var reconnectAttempts = 10;
             var reconnectDelay = 1000;
             var serviceClient = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration);
             if (serviceClient == null) {
            Console.Error.WriteLine("Failed to connect to endpoint.");
            return 1;
             } else {
            var dispatcher = new DispatcherCommand("registered commands");
            dispatcher.RegisterCommand(new ShutdownCommand(serviceClient));
            //            dispatcher.RegisterCommand(new ModCommand(serviceClient));
            dispatcher.RegisterCommand(new ExitCommand());
            dispatcher.RegisterCommand(new ServiceCommand(serviceClient));

            var repl = new DargonREPL(dispatcher);
            repl.Run();
            return 0;
             }
        }
Exemple #9
0
        private ServiceClientFactoryImpl CreateServiceClientFactory(params PofContext[] pofContexts)
        {
            var proxyGenerator = new ProxyGenerator();
            ICollectionFactory      collectionFactory            = new CollectionFactory();
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            IStreamFactory             streamFactory             = new StreamFactory();
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            PofContext                 pofContext                = new DspPofContext();

            pofContexts.ForEach(pofContext.MergeContext);
            IPofSerializer                 pofSerializer                  = new PofSerializer(pofContext);
            PofStreamsFactory              pofStreamsFactory              = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);
            PortableObjectBoxConverter     portableObjectBoxConverter     = new PortableObjectBoxConverter(streamFactory, pofSerializer);
            InvokableServiceContextFactory invokableServiceContextFactory = new InvokableServiceContextFactoryImpl(collectionFactory, portableObjectBoxConverter);

            return(new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory));
        }
        public static void EntryPoint(int i, CourierNetwork network)
        {
            ICollectionFactory      collectionFactory      = new CollectionFactory();
            ObjectPoolFactory       objectPoolFactory      = new DefaultObjectPoolFactory(collectionFactory);
            IThreadingFactory       threadingFactory       = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory = new SynchronizationFactory();
            IThreadingProxy         threadingProxy         = new ThreadingProxy(threadingFactory, synchronizationFactory);
            GuidProxy      guidProxy         = new GuidProxyImpl();
            IPofContext    courierPofContext = new DargonCourierImplPofContext();
            IPofSerializer courierSerializer = new PofSerializer(courierPofContext);
            Guid           localIdentifier   = guidProxy.NewGuid();
            var            endpoint          = new CourierEndpointImpl(courierSerializer, localIdentifier, "node" + i);
            var            networkContext    = network.Join(endpoint);

            var networkBroadcaster = new NetworkBroadcasterImpl(endpoint, networkContext, courierSerializer);
            var messageContextPool = objectPoolFactory.CreatePool(() => new UnacknowledgedReliableMessageContext());
            var unacknowledgedReliableMessageContainer = new UnacknowledgedReliableMessageContainer(messageContextPool);
            var messageDtoPool      = objectPoolFactory.CreatePool(() => new CourierMessageV1());
            var messageTransmitter  = new MessageTransmitterImpl(guidProxy, courierSerializer, networkBroadcaster, unacknowledgedReliableMessageContainer, messageDtoPool);
            var messageSender       = new MessageSenderImpl(guidProxy, unacknowledgedReliableMessageContainer, messageTransmitter);
            var acknowledgeDtoPool  = objectPoolFactory.CreatePool(() => new CourierMessageAcknowledgeV1());
            var messageAcknowledger = new MessageAcknowledgerImpl(networkBroadcaster, unacknowledgedReliableMessageContainer, acknowledgeDtoPool);
            var periodicAnnouncer   = new PeriodicAnnouncerImpl(threadingProxy, courierSerializer, endpoint, networkBroadcaster);

            periodicAnnouncer.Start();
            var periodicResender = new PeriodicResenderImpl(threadingProxy, unacknowledgedReliableMessageContainer, messageTransmitter);

            periodicResender.Start();

            ReceivedMessageFactory receivedMessageFactory = new ReceivedMessageFactoryImpl(courierSerializer);
            MessageRouter          messageRouter          = new MessageRouterImpl(receivedMessageFactory);
            var peerRegistry    = new PeerRegistryImpl(courierSerializer);
            var networkReceiver = new NetworkReceiverImpl(endpoint, networkContext, courierSerializer, messageRouter, messageAcknowledger, peerRegistry);

            networkReceiver.Initialize();

            messageRouter.RegisterPayloadHandler <string>(m => {
//            Console.WriteLine(i + ": " + m.Payload);
            });

            Thread.Sleep(3000);

            if (i == 0)
            {
                while (true)
                {
                    for (var j = 0; j < 50; j++)
                    {
                        Console.WriteLine(unacknowledgedReliableMessageContainer.GetUnsentMessagesRemaining() + " pending");
                        var stopwatch = new Stopwatch();
                        stopwatch.Start();
                        var messagesRemaining = unacknowledgedReliableMessageContainer.GetUnsentMessagesRemaining();
                        var peers             = peerRegistry.EnumeratePeers().ToArray();
                        for (var k = 0; k < 10000; k++)
                        {
                            foreach (var peer in peers)
                            {
                                messageSender.SendReliableUnicast(peer.Id, "Message " + j + " hello from " + i + ", " + peer.Id, MessagePriority.Low);
                            }
                        }
                        var messagesAcked = unacknowledgedReliableMessageContainer.GetUnsentMessagesRemaining() - messagesRemaining + 10000;
                        Console.WriteLine("Got " + (messagesAcked * peers.Length) + " acks in " + stopwatch.ElapsedMilliseconds + "ms (" + (messagesAcked * peers.Length / stopwatch.Elapsed.TotalSeconds) + " per second) " + messagesRemaining + " remaining");
                        Thread.Sleep(1);
                    }

                    for (var j = 0; j < 1000; j++)
                    {
                        Console.WriteLine(unacknowledgedReliableMessageContainer.GetUnsentMessagesRemaining() + " pending");
                        Thread.Sleep(1);
                    }
                }
            }
        }
Exemple #11
0
        public static void Main(string[] args)
        {
            InitializeLogging();
            // construct libwarty dependencies
            ICollectionFactory collectionFactory = new CollectionFactory();

            // construct libwarty-proxies dependencies
            IStreamFactory          streamFactory                = new StreamFactory();
            IFileSystemProxy        fileSystemProxy              = new FileSystemProxy(streamFactory);
            IThreadingFactory       threadingFactory             = new ThreadingFactory();
            ISynchronizationFactory synchronizationFactory       = new SynchronizationFactory();
            IThreadingProxy         threadingProxy               = new ThreadingProxy(threadingFactory, synchronizationFactory);
            IDnsProxy                  dnsProxy                  = new DnsProxy();
            ITcpEndPointFactory        tcpEndPointFactory        = new TcpEndPointFactory(dnsProxy);
            INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory);
            ISocketFactory             socketFactory             = new SocketFactory(tcpEndPointFactory, networkingInternalFactory);
            INetworkingProxy           networkingProxy           = new NetworkingProxy(socketFactory, tcpEndPointFactory);
            IProcessProxy              processProxy              = new ProcessProxy();

            // construct Castle.Core dependencies
            ProxyGenerator proxyGenerator = new ProxyGenerator();

            // construct Platform Root Portable Object Format dependencies
            IPofContext    pofContext    = new PlatformPofContext();
            IPofSerializer pofSerializer = new PofSerializer(pofContext);

            // construct libdargon.management dependencies
            var                            managementServerEndpoint      = tcpEndPointFactory.CreateAnyEndPoint(kPlatformManagementPort);
            IMessageFactory                managementMessageFactory      = new MessageFactory();
            IManagementSessionFactory      managementSessionFactory      = new ManagementSessionFactory(collectionFactory, threadingProxy, pofSerializer, managementMessageFactory);
            ILocalManagementServerContext  managementServerContext       = new LocalManagementServerContext(collectionFactory, managementSessionFactory);
            IManagementContextFactory      managementContextFactory      = new ManagementContextFactory(pofContext);
            ILocalManagementRegistry       localManagementServerRegistry = new LocalManagementRegistry(pofSerializer, managementContextFactory, managementServerContext);
            IManagementServerConfiguration managementServerConfiguration = new ManagementServerConfiguration(managementServerEndpoint);
            var                            server = new LocalManagementServer(threadingProxy, networkingProxy, managementSessionFactory, managementServerContext, managementServerConfiguration);

            server.Initialize();

            // construct system-state dependencies
            ICache <string, string> systemStateCache = new InMemoryCache <string, string>("SystemState", new ICacheIndex[0]);
            var platformSystemState = new PlatformSystemStateImpl(systemStateCache);

            localManagementServerRegistry.RegisterInstance(new PlatformSystemStateMob(platformSystemState));

            // construct platform foundational dependencies
            ICacheFactory        cacheFactory         = new CacheFactory();
            PlatformCacheService platformCacheService = new PlatformCacheServiceImpl(collectionFactory, cacheFactory).With(x => x.Initialize());
            Caches specializedCaches = new Caches(platformCacheService);
            SpecializedCacheService specializedCacheService = new SpecializedCacheServiceImpl(specializedCaches);

            // construct backend account service dependencies
            ICache <string, long>             emailToAccountIdCache = new InMemoryCache <string, long>(Accounts.Hydar.CacheNames.kEmailToAccountIdCache, new ICacheIndex[0]);
            ICache <long, AccountInformation> accountInfoByIdCache  = new InMemoryCache <long, AccountInformation>(Accounts.Hydar.CacheNames.kAccountInfoByIdCache, new ICacheIndex[0]);
            IDistributedCounter accountIdCounter  = specializedCacheService.GetCountingCache(Accounts.Hydar.CacheNames.kAccountIdCountingCacheName);
            IPasswordUtilities  passwordUtilities = new PasswordUtilities();
            AccountCache        accountCache      = new AccountCache(emailToAccountIdCache, accountInfoByIdCache, accountIdCounter, passwordUtilities);
            var accountService = new AccountServiceImpl(accountCache);

            localManagementServerRegistry.RegisterInstance(new AccountCacheMob(accountCache));

            // construct frontend identity service dependencies
            ICache <string, Identity>           identityByTokenHydarCache          = new InMemoryCache <string, Identity>(Draek.Identities.Hydar.CacheNames.kIdentityByTokenCache, new ICacheIndex[0]);
            AuthenticationTokenFactory          authenticationTokenFactory         = new AuthenticationTokenFactoryImpl();
            IdentityByTokenCache                identityByTokenCache               = new IdentityByTokenCacheImpl(identityByTokenHydarCache);
            IAuthenticationServiceConfiguration authenticationServiceConfiguration = new AuthenticationServiceConfiguration(platformSystemState);
            AuthenticationService               authenticationService              = new AuthenticationServiceImpl(accountService, authenticationTokenFactory, identityByTokenCache, authenticationServiceConfiguration);
            var identityService = new IdentityServiceProxyImpl(authenticationService);

            localManagementServerRegistry.RegisterInstance(new AuthenticationServiceMob(authenticationService));
            localManagementServerRegistry.RegisterInstance(new IdentityCacheMob(identityByTokenCache));
            localManagementServerRegistry.RegisterInstance(new AuthenticationServiceConfigurationMob(authenticationServiceConfiguration));

            Application.Run();
        }