Beispiel #1
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _injector            = injector;
            _applicationId       = applicationId;
            _evaluatorId         = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig        = new ContextConfiguration(rootContextConfigString);
            _rootTaskConfiguration    = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager  = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _injector = injector;
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig = new ContextConfiguration(rootContextConfigString);
            _rootTaskConfiguration = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
Beispiel #3
0
        private NetworkTransport(
            ILocalAddressProvider localAddressProvider,
            ProtocolSerializer serializer,
            LocalObserver localObserver,
            IRemoteManagerFactory remoteManagerFactory,
            REEFFileNames fileNames)
        {
            _serializer = serializer;
            _fileNames  = fileNames;

            // Instantiate the remote manager.
            _remoteManager = remoteManagerFactory.GetInstance(localAddressProvider.LocalAddress, new ByteCodec());

            // Listen to the java bridge on the local end point.
            _remoteManager.RegisterObserver(localObserver);
            Logger.Log(Level.Info, "Local observer listening to java bridge on: [{0}]", _remoteManager.LocalEndpoint);

            // Instantiate a remote observer to send messages to the java bridge.
            IPEndPoint javaIpEndPoint = GetJavaBridgeEndpoint();

            Logger.Log(Level.Info, "Connecting to java bridge on: [{0}]", javaIpEndPoint);
            _remoteObserver = _remoteManager.GetRemoteObserver(javaIpEndPoint);

            // Negotiate the protocol.
            Send(0, new BridgeProtocol(100));
        }
Beispiel #4
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     IClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries,
          clock, remoteManagerFactory, reefMessageCodec, null)
 {
 }
Beispiel #5
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     IClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, 
     clock, remoteManagerFactory, reefMessageCodec, null)
 {
 }
Beispiel #6
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
     AvroConfigurationSerializer serializer,
     RuntimeClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec,
     IInjector injector) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, rootContextConfigString, serializer,
     clock, remoteManagerFactory, reefMessageCodec, injector, null)
 {
 }
Beispiel #7
0
 private EvaluatorSettings(
     [Parameter(typeof(ApplicationIdentifier))] string applicationId,
     [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
     [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
     [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
     [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
     AvroConfigurationSerializer serializer,
     RuntimeClock clock,
     IRemoteManagerFactory remoteManagerFactory,
     REEFMessageCodec reefMessageCodec,
     IInjector injector) :
     this(applicationId, evaluatorId, heartbeatPeriodInMs, maxHeartbeatRetries, rootContextConfigString, serializer,
          clock, remoteManagerFactory, reefMessageCodec, injector, null)
 {
 }
Beispiel #8
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            [Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
            AvroConfigurationSerializer serializer,
            RuntimeClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            IInjector injector)
        {
            _serializer = serializer;
            _injector = injector;
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            if (string.IsNullOrWhiteSpace(rootContextConfigString))
            {
                Utilities.Diagnostics.Exceptions.Throw(
                    new ArgumentException("empty or null rootContextConfigString"), Logger);
            }
            _rootContextConfig = _serializer.FromString(rootContextConfigString);

            try
            {
                _rootContextId = injector.ForkInjector(_rootContextConfig).GetNamedInstance<ContextConfigurationOptions.ContextIdentifier, string>();
            }
            catch (InjectionException)
            {
                Logger.Log(Level.Info, "Using deprecated ContextConfiguration.");
                
                // TODO[JIRA REEF-1167]: Remove this catch.
                var deprecatedContextConfig = new Context.ContextConfiguration(rootContextConfigString);
                _rootContextConfig = deprecatedContextConfig;
                _rootContextId = deprecatedContextConfig.Id;
            }

            _rootTaskConfiguration = CreateTaskConfiguration();
            _rootServiceConfiguration = CreateRootServiceConfiguration();

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            _operationState = EvaluatorOperationState.OPERATIONAL;
        }
Beispiel #9
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            IClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            INameClient nameClient)
        {
            _applicationId       = applicationId;
            _evaluatorId         = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            OperationState = EvaluatorOperationState.OPERATIONAL;
            NameClient     = nameClient;
        }
Beispiel #10
0
        public NetworkService(
            [Parameter(typeof(NetworkServiceOptions.NetworkServicePort))] int nsPort,
            IObserver <NsMessage <T> > messageHandler,
            IIdentifierFactory idFactory,
            ICodec <T> codec,
            INameClient nameClient,
            IRemoteManagerFactory remoteManagerFactory)
        {
            _codec = new NsMessageCodec <T>(codec, idFactory);

            IPAddress localAddress = NetworkUtils.LocalIPAddress;

            _remoteManager  = remoteManagerFactory.GetInstance(localAddress, nsPort, _codec);
            _messageHandler = messageHandler;

            NamingClient   = nameClient;
            _connectionMap = new Dictionary <IIdentifier, IConnection <T> >();

            LOGGER.Log(Level.Info, "Started network service");
        }
Beispiel #11
0
        private EvaluatorSettings(
            [Parameter(typeof(ApplicationIdentifier))] string applicationId,
            [Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
            [Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
            [Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
            IClock clock,
            IRemoteManagerFactory remoteManagerFactory,
            REEFMessageCodec reefMessageCodec,
            INameClient nameClient)
        {
            _applicationId = applicationId;
            _evaluatorId = evaluatorId;
            _heartBeatPeriodInMs = heartbeatPeriodInMs;
            _maxHeartbeatRetries = maxHeartbeatRetries;
            _clock = clock;

            _remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
            OperationState = EvaluatorOperationState.OPERATIONAL;
            NameClient = nameClient;
        }
Beispiel #12
0
        public void TestTwoWayCommunication()
        {
            // Test data.
            int[]    numbers = { 12, 25 };
            string[] strings = { "The first string", "The second string" };

            IPAddress listeningAddress         = IPAddress.Parse("127.0.0.1");
            BlockingCollection <byte[]> queue1 = new BlockingCollection <byte[]>();
            BlockingCollection <byte[]> queue2 = new BlockingCollection <byte[]>();

            ProtocolSerializer    serializer            = new ProtocolSerializer(this.GetType().Assembly, "org.apache.reef.wake.tests.message");
            IRemoteManagerFactory _remoteManagerFactory = TangFactory.GetTang().NewInjector().GetInstance <IRemoteManagerFactory>();

            using (var remoteManager1 = _remoteManagerFactory.GetInstance(listeningAddress, new ByteCodec()))
                using (var remoteManager2 = _remoteManagerFactory.GetInstance(listeningAddress, new ByteCodec()))
                {
                    // Register observers for remote manager 1 and remote manager 2
                    var remoteEndpoint = new IPEndPoint(listeningAddress, 0);
                    remoteManager1.RegisterObserver(remoteEndpoint, Observer.Create <byte[]>(queue1.Add));
                    remoteManager2.RegisterObserver(remoteEndpoint, Observer.Create <byte[]>(queue2.Add));

                    var msg1 = new AvroTestMessage(numbers[0], strings[0]);
                    var msg2 = new AvroTestMessage(numbers[1], strings[1]);

                    // Remote manager 1 sends avro message to remote manager 2
                    var remoteObserver1 = remoteManager1.GetRemoteObserver(remoteManager2.LocalEndpoint);
                    remoteObserver1.OnNext(serializer.Write(msg1, 1));

                    // Remote manager 2 sends avro message to remote manager 1
                    var remoteObserver2 = remoteManager2.GetRemoteObserver(remoteManager1.LocalEndpoint);
                    remoteObserver2.OnNext(serializer.Write(msg2, 2));

                    // Verify the messages are properly received.
                    serializer.Read(queue1.Take(), new TestMessageObserver(2, msg2));
                    serializer.Read(queue2.Take(), new TestMessageObserver(1, msg1));
                }
        }