/** {@inheritDoc} */ @Override public void deregisterPorts(Class<?> cls) { ctx.ports().deregisterPorts(cls); } }
/** {@inheritDoc} */ @Override public void registerPort(int port, IgnitePortProtocol proto, Class<?> cls) { ctx.ports().registerPort(port, proto, cls); }
/** {@inheritDoc} */ @Override public void deregisterPort(int port, IgnitePortProtocol proto, Class<?> cls) { ctx.ports().deregisterPort(port, proto, cls); }
@Override public void deregisterPort(int port, IgnitePortProtocol proto) { ctx.ports().deregisterPort(port, proto, spi.getClass()); }
@Override public void registerPort(int port, IgnitePortProtocol proto) { ctx.ports().registerPort(port, proto, spi.getClass()); }
@Override public void deregisterPorts() { ctx.ports().deregisterPorts(spi.getClass()); }
ctx.ports().deregisterPorts(getClass());
/** * Get registered port * * @param protoCls Protocol class. * @param def Default value if such class is not registered. * @return Registered port for the protocol class or {@code default value if such class is not registered. */ private int getRegisteredPort(Class<? extends GridRestProtocol> protoCls, int def) { for (GridPortRecord r : ctx.ports().records()) { if (r.protocol() == IgnitePortProtocol.TCP && protoCls.isAssignableFrom(r.clazz())) return r.port(); } return def; }
/** {@inheritDoc} */ @Override public void stop() { if (srv != null) { ctx.ports().deregisterPorts(getClass()); srv.stop(); } if (log.isInfoEnabled()) log.info(stopInfo()); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { if (srv != null) { busyLock.block(); srv.stop(); ctx.ports().deregisterPorts(getClass()); if (execSvc != null) { U.shutdownNow(getClass(), execSvc, log); execSvc = null; } if (!U.IGNITE_MBEANS_DISABLED) unregisterMBean(); if (log.isDebugEnabled()) log.debug("Client connector processor stopped."); } }
/** * Create SQL connection to node specified as argument * * @param node Node to connect. * @return Connection. * @throws SQLException In case of failure. */ private static Connection connect(IgniteEx node) throws SQLException { Collection<GridPortRecord> recs = node.context().ports().records(); GridPortRecord cliLsnrRec = null; for (GridPortRecord rec : recs) { if (rec.clazz() == ClientListenerProcessor.class) { cliLsnrRec = rec; break; } } String connStr = "jdbc:ignite:thin://127.0.0.1:" + cliLsnrRec.port(); return DriverManager.getConnection(connStr); }
/** * @param node Node to connect to. * @return Thin JDBC connection to specified node. */ public static Connection connect(IgniteEx node) { Collection<GridPortRecord> recs = node.context().ports().records(); GridPortRecord cliLsnrRec = null; for (GridPortRecord rec : recs) { if (rec.clazz() == ClientListenerProcessor.class) { cliLsnrRec = rec; break; } } assertNotNull(cliLsnrRec); try { return DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:" + cliLsnrRec.port()); } catch (SQLException e) { throw new AssertionError(e); } }
ctx.ports().registerPort(connPort, TCP, getClass());
/** * @param node Node to connect to. * @param params Connection parameters. * @return Thin JDBC connection to specified node. */ public static Connection connect(IgniteEx node, String params) throws SQLException { Collection<GridPortRecord> recs = node.context().ports().records(); GridPortRecord cliLsnrRec = null; for (GridPortRecord rec : recs) { if (rec.clazz() == ClientListenerProcessor.class) { cliLsnrRec = rec; break; } } assertNotNull(cliLsnrRec); String connStr = "jdbc:ignite:thin://127.0.0.1:" + cliLsnrRec.port(); if (!F.isEmpty(params)) connStr += "/?" + params; return DriverManager.getConnection(connStr); }
/** * @param node Node to connect to. * @param params Connection parameters. * @return Thin JDBC connection to specified node. */ protected Connection connect(IgniteEx node, String params) throws SQLException { Collection<GridPortRecord> recs = node.context().ports().records(); GridPortRecord cliLsnrRec = null; for (GridPortRecord rec : recs) { if (rec.clazz() == ClientListenerProcessor.class) { cliLsnrRec = rec; break; } } assertNotNull(cliLsnrRec); String connStr = "jdbc:ignite:thin://127.0.0.1:" + cliLsnrRec.port(); if (!F.isEmpty(params)) connStr += "/?" + params; return DriverManager.getConnection(connStr); }
igfsCtx.kernalContext().ports().registerPort(srvEndpoint.getPort(), TCP, srvEndpoint.getClass());
igfsCtx.kernalContext().ports().deregisterPort(srvEndpoint.getPort(), TCP, srvEndpoint.getClass());
/** {@inheritDoc} */ @Override public void start(HadoopContext ctx) throws IgniteCheckedException { this.ctx = ctx; log = ctx.kernalContext().log(HadoopExternalTaskExecutor.class); outputBase = U.resolveWorkDirectory(ctx.kernalContext().config().getWorkDirectory(), "hadoop", false); pathSep = System.getProperty("path.separator", U.isWindows() ? ";" : ":"); initJavaCommand(); comm = new HadoopExternalCommunication( ctx.localNodeId(), UUID.randomUUID(), ctx.kernalContext().config().getMarshaller(), log, ctx.kernalContext().getSystemExecutorService(), ctx.kernalContext().igniteInstanceName(), ctx.kernalContext().config().getWorkDirectory()); comm.setListener(new MessageListener()); comm.start(); nodeDesc = comm.localProcessDescriptor(); ctx.kernalContext().ports().registerPort(nodeDesc.tcpPort(), IgnitePortProtocol.TCP, HadoopExternalTaskExecutor.class); if (nodeDesc.sharedMemoryPort() != -1) ctx.kernalContext().ports().registerPort(nodeDesc.sharedMemoryPort(), IgnitePortProtocol.TCP, HadoopExternalTaskExecutor.class); jobTracker = ctx.jobTracker(); }
/** * Counts all registered IPC endpoints. * * @return Tuple2 where (tcp endpoints count, shmem endpoints count). * @throws Exception If failed. */ protected T2<Integer, Integer> checkRegisteredIpcEndpoints() throws Exception { GridKernalContext ctx = ((IgniteKernal)grid()).context(); int tcp = 0; int shmem = 0; for (GridPortRecord record : ctx.ports().records()) { if (record.clazz() == IpcSharedMemoryServerEndpoint.class) shmem++; else if (record.clazz() == IpcServerTcpEndpoint.class) tcp++; } return new T2<>(tcp, shmem); }
/** * @throws Exception If any error occurs. */ @Test public void testMulticastIpFinder() throws Exception { try { for (int i = 0; i < 5; i++) { Ignite g = startGrid("MulticastIpFinder-" + i); assertEquals(i + 1, g.cluster().nodes().size()); TcpDiscoverySpi spi = (TcpDiscoverySpi)g.configuration().getDiscoverySpi(); TcpDiscoveryMulticastIpFinder ipFinder = (TcpDiscoveryMulticastIpFinder)spi.getIpFinder(); boolean found = false; for (GridPortRecord rec : ((IgniteKernal) g).context().ports().records()) { if ((rec.protocol() == UDP) && rec.port() == ipFinder.getMulticastPort()) { found = true; break; } } assertTrue("TcpDiscoveryMulticastIpFinder should register port." , found); } } finally { stopAllGrids(); } }