Example #1
0
        public void Connect(object credentials)
        {
            object          token;
            IRemotingServer server = (IRemotingServer)Activator.GetObject(typeof(IRemotingServer), _serviceUrl.ToString());

            _connection       = server.NewClient(credentials, out token);
            _token            = token;
            _serverConnection = new RemotingMBeanServerConnection(_connection, _token);
            _fetcher          = new NotificationFetcher(_fetcherConfig, _connection, _serverConnection);
        }
 public NotificationFetcher(NotificationFetcherConfig fetcherConfig, IRemotingConnection connection, RemotingMBeanServerConnection serverConnection)
 {
     _connection = connection;
     _serverConnection = serverConnection;
     _maxBatchSize = fetcherConfig.MaxNotificationBatchSize;
     if (fetcherConfig.Proactive)
     {
         _timer = new Timer(FetchNotifications, null, TimeSpan.Zero, fetcherConfig.FetchDelay);
     }
     else
     {
         FetchNotifications(null);
     }
 }
Example #3
0
 public void Close()
 {
     if (_connection != null)
     {
         if (_fetcher != null)
         {
             _fetcher.Dispose();
             _fetcher = null;
         }
         _serverConnection = null;
         _connection.Close();
         _connection = null;
     }
 }
Example #4
0
 public void Close()
 {
     if (_connection != null)
     {
         if (_fetcher != null)
         {
             _fetcher.Dispose();
             _fetcher = null;
         }
         _serverConnection = null;
         _connection.Close();
         _connection = null;
     }
 }
Example #5
0
 public NotificationFetcher(NotificationFetcherConfig fetcherConfig, IRemotingConnection connection, RemotingMBeanServerConnection serverConnection)
 {
     _connection       = connection;
     _serverConnection = serverConnection;
     _maxBatchSize     = fetcherConfig.MaxNotificationBatchSize;
     if (fetcherConfig.Proactive)
     {
         _timer = new Timer(FetchNotifications, null, TimeSpan.Zero, fetcherConfig.FetchDelay);
     }
     else
     {
         FetchNotifications(null);
     }
 }
Example #6
0
 private RemotingConnector(SerializationInfo info, StreamingContext context)
 {
     string connectionId = info.GetString("connectionId");
     _serviceUrl = new Uri(info.GetString("serviceUrl"));
     string typeString = info.GetString("tokenType");
     if (typeString != null)
     {
         Type tokenType = Type.GetType(typeString, true);
         _token = info.GetValue("token", tokenType);
     }
     _fetcherConfig = (NotificationFetcherConfig) info.GetValue("fetcherConfig", typeof(NotificationFetcherConfig));
     if (connectionId != null)
     {
         IRemotingServer server = (IRemotingServer)Activator.GetObject(typeof(IRemotingServer), _serviceUrl.ToString());
         _connection = server.Reconnect(connectionId);
         _serverConnection = new RemotingMBeanServerConnection(_connection, _token);
         _fetcher = new NotificationFetcher(_fetcherConfig, _connection, _serverConnection);
     }
 }
Example #7
0
        private RemotingConnector(SerializationInfo info, StreamingContext context)
        {
            string connectionId = info.GetString("connectionId");

            _serviceUrl = new Uri(info.GetString("serviceUrl"));
            string typeString = info.GetString("tokenType");

            if (typeString != null)
            {
                Type tokenType = Type.GetType(typeString, true);
                _token = info.GetValue("token", tokenType);
            }
            _fetcherConfig = (NotificationFetcherConfig)info.GetValue("fetcherConfig", typeof(NotificationFetcherConfig));
            if (connectionId != null)
            {
                IRemotingServer server = (IRemotingServer)Activator.GetObject(typeof(IRemotingServer), _serviceUrl.ToString());
                _connection       = server.Reconnect(connectionId);
                _serverConnection = new RemotingMBeanServerConnection(_connection, _token);
                _fetcher          = new NotificationFetcher(_fetcherConfig, _connection, _serverConnection);
            }
        }
        public void Dispose()
        {
            if (_disposed)
                return;

            _disposed = true;

            WriteLine("Disposing engine client ...");

            if (_process != null)
            {
                _process.Dispose();
                _process = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }

            WriteLine("... disposed engine client");
        }
        public void Initialise(string initialisingXml, IDocumentAccessor accessor)
        {
            try
            {
                _initialisingXml = XElement.Parse(initialisingXml);

                var arguments = Persistence.Arguments
                    .Parse(_initialisingXml, accessor);

                var remotingId = BaseComponentWithEngine.GetArgumentIdentity(
                    BaseComponentWithEngine.ArgsWithEngine.Remoting).Id;
                var diagnosticsId = BaseComponentWithEngine.GetArgumentIdentity(
                    BaseComponentWithEngine.ArgsWithEngine.Diagnostics).Id;

                var remoting = arguments
                    .Where(a => a.Id == remotingId)
                    .Single();

                var diagnostics = arguments
                    .Where(a => a.Id == diagnosticsId)
                    .Single();

                _remotingData = new ParametersRemoting();
                _remotingData.ValueAsString = remoting.ValueAsString;

                _diagnostics = new ParametersDiagnosticsNative();
                _diagnostics.ValueAsString = diagnostics.ValueAsString;

                if (_remotingData.Protocol == RemotingProtocol.ipcAuto)
                {
                    string args = string.Format(
                        "ipcAuto {0} {1}", _remotingData.ObjectUri, _remotingData.PortName);

                    if (_remotingData.ServerLaunchDebugger)
                        args += " launchDebugger";
                    if (_remotingData.EnsureSecurity)
                        args += " ensureSecurity";
                    if (_remotingData.ServerTraceEngine)
                        args += " traceEngine";

                    var serverType = new ExternalType(typeof(RemotingServerEngineTime));

                    WriteLine("IPC Auto Process");
                    WriteLine("\tServer: " + serverType.Url.LocalPath, false);
                    WriteLine("\tArgs: " + args, false);
                    WriteLine("\tRedirect Standard Output (if true could be VERY slow): "
                        + _remotingData.IpcAutoRedirectStdOut.ToString(), false);

                    _process = new RemotingProcess("RemotingServerEngineTime");
                    _process.Start(serverType.Url.LocalPath, args, _remotingData.IpcAutoRedirectStdOut);

                    WriteLine("Process started");
                }

                WriteLine(_remotingData.Details());

                switch (_remotingData.Protocol)
                {
                    case RemotingProtocol.ipc:
                    case RemotingProtocol.ipcAuto:
                        WriteLine("IPC Connection");
                        _connection = new RemotingConnectionIpc();
                        break;
                    case RemotingProtocol.tcp:
                        WriteLine("TCP Connection");
                        _connection = new RemotingConnectionTcp();
                        break;
                    case RemotingProtocol.http:
                        WriteLine("HTTP Connection");
                        _connection = new RemotingConnectionHttp();
                        break;
                    case RemotingProtocol.inProcess:
                    default:
                        throw new NotImplementedException(_remotingData.Protocol.ToString());
                }

                WriteLine("\tClient Uri: " + _remotingData.ClientUri, false);
                WriteLine("\tEnsure Security: " + _remotingData.EnsureSecurity, false);
                WriteLine("\tConnection TimeOut: " + _remotingData.ConnectionTimeOut, false);

                _connection.Start(_remotingData.ClientUri, _remotingData.EnsureSecurity, _remotingData.ConnectionTimeOut, typeof(IEngine));

                WriteLine("\tConnection started.", false);
                WriteLine(string.Format("... pause {0} seconds before pinging engine ...", _remotingData.ConnectionSleep / 1000.0));

                Thread.Sleep(_remotingData.ConnectionSleep);

                string ping = EngineProxy.Ping();

                WriteLine("Engine Ping: " + ping);

                WriteLine("Engine Initialising ...");
                EngineProxy.Initialise(_initialisingXml.ToString());
                WriteLine("\tInitialised.", false);
            }
            catch (System.Exception e)
            {
                throw EngineMethodCatch("Initialise", e);
            }
        }
 public RemotingMBeanServerConnection(IRemotingConnection connection, object token)
 {
     _connection = connection;
     _token = token;
 }
Example #11
0
 public void Connect(object credentials)
 {
     object token;
     IRemotingServer server = (IRemotingServer)Activator.GetObject(typeof(IRemotingServer), _serviceUrl.ToString());
     _connection = server.NewClient(credentials, out token);
     _token = token;
     _serverConnection = new RemotingMBeanServerConnection(_connection, _token);
     _fetcher = new NotificationFetcher(_fetcherConfig, _connection, _serverConnection);
 }
 public RemotingMBeanServerConnection(IRemotingConnection connection, object token)
 {
     _connection = connection;
     _token      = token;
 }