Exemplo n.º 1
0
        protected override IIdentityLookup GetIdentityLookup(string clusterName)
        {
            var pids     = MongoFixture.Database.GetCollection <PidLookupEntity>("pids");
            var identity = new IdentityStorageLookup(new FailureInjectionStorage(new MongoIdentityStorage(clusterName, pids)));

            return(identity);
        }
Exemplo n.º 2
0
        public static async Task Main()
        {
            /*
             *  docker build . -t rogeralsing/kubdiagg
             *  kubectl apply --filename service.yaml
             *  kubectl get pods -l app=kubdiag
             *  kubectl logs -l app=kubdiag --all-containers
             *
             */

            var l = LoggerFactory.Create(c => c.AddConsole().SetMinimumLevel(LogLevel.Error));

            Log.SetLoggerFactory(l);
            var log = Log.CreateLogger("main");

            var db       = GetMongo();
            var identity = new IdentityStorageLookup(new MongoIdentityStorage("mycluster", db.GetCollection <PidLookupEntity>("pids"), 200));

            var kubernetes      = new Kubernetes(KubernetesClientConfiguration.InClusterConfig());
            var clusterprovider = new KubernetesProvider(kubernetes);

            var port           = int.Parse(Environment.GetEnvironmentVariable("PROTOPORT") !);
            var host           = Environment.GetEnvironmentVariable("PROTOHOST");
            var advertisedHost = Environment.GetEnvironmentVariable("PROTOHOSTPUBLIC");

            log.LogInformation("Host {host}", host);
            log.LogInformation("Port {port}", port);
            log.LogInformation("Advertised Host {advertisedHost}", advertisedHost);

            var system = new ActorSystem()
                         .WithRemote(GrpcNetRemoteConfig
                                     .BindTo(host, port)
                                     .WithAdvertisedHost(advertisedHost)
                                     )
                         .WithCluster(ClusterConfig
                                      .Setup("mycluster", clusterprovider, identity)
                                      .WithClusterKind("empty", Props.Empty)
                                      );

            system.EventStream.Subscribe <ClusterTopology>(e => {
                var members = e.Members;
                var x       = members.Select(m => m.Id).OrderBy(i => i).ToArray();
                var key     = string.Join("", x);
                var hash    = MurmurHash2.Hash(key);

                Console.WriteLine("My members " + hash);

                foreach (var member in members.OrderBy(m => m.Id))
                {
                    Console.WriteLine(member.Id + "\t" + member.Address + "\t" + member.Kinds);
                }
            }
                                                           );

            await system
            .Cluster()
            .StartMemberAsync();

            Thread.Sleep(Timeout.Infinite);
        }
        public static IIdentityLookup GetIdentityLookup(string clusterName, string host, string port)
        {
            ConnectionMultiplexer muxer = ConnectionMultiplexer.Connect($"{host}:{port}");
            var identity = new IdentityStorageLookup(new RedisIdentityStorage(clusterName, muxer));

            return(identity);
        }
Exemplo n.º 4
0
        protected override IIdentityLookup GetIdentityLookup(string clusterName)
        {
            var identity = new IdentityStorageLookup(
                new FailureInjectionStorage(new RedisIdentityStorage(clusterName, RedisFixture.Multiplexer, TimeSpan.FromSeconds(10)))
                );

            return(identity);
        }
Exemplo n.º 5
0
        public static IIdentityLookup GetIdentityLookup(string clusterName, string connectionString, string pidCollection, string pidDatabaseName)
        {
            var db       = GetMongo(connectionString, pidDatabaseName);
            var identity = new IdentityStorageLookup(
                new MongoIdentityStorage(clusterName, db.GetCollection <PidLookupEntity>(pidCollection), 200)
                );

            return(identity);
        }
        private static IIdentityLookup GetMongoIdentityLookup()
        {
            var db       = GetMongo();
            var identity = new IdentityStorageLookup(
                new MongoIdentityStorage("mycluster", db.GetCollection <PidLookupEntity>("pids"), 200)
                );

            return(identity);
        }
Exemplo n.º 7
0
        protected override IIdentityLookup GetIdentityLookup(string clusterName)
        {
            var identity = new IdentityStorageLookup(new RedisIdentityStorage(clusterName, RedisFixture.Multiplexer));

            return(identity);
        }