@Override public TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
public static void encode(HornetQBuffer buffer, TransportConfiguration config) { BufferHelper.writeAsNullableSimpleString(buffer, config.getName()); BufferHelper.writeAsSimpleString(buffer, config.getFactoryClassName()); buffer.writeInt(config.getParams().size()); for (Entry<String, Object> param : config.getParams().entrySet()) { BufferHelper.writeAsSimpleString(buffer, param.getKey()); BufferHelper.writeAsSimpleString(buffer, param.getValue().toString()); } }
@Override public void decodeRest(final HornetQBuffer buffer) { clusterUser = buffer.readString(); clusterPassword = buffer.readString(); backupWantsFailBack = buffer.readBoolean(); connector = new TransportConfiguration(); connector.decode(buffer); }
connectorFactory = instantiateConnectorFactory(connectorConfig.getFactoryClassName()); checkTransportKeys(connectorFactory, connectorConfig.getParams());
private ClusterConnection lookupClusterConnection(TransportConfiguration acceptorConfig) { String clusterConnectionName = (String) acceptorConfig.getParams().get(org.hornetq.core.remoting.impl.netty.TransportConstants.CLUSTER_CONNECTION); ClusterConnection clusterConnection = null; if (clusterConnectionName != null) { clusterConnection = clusterManager.getClusterConnection(clusterConnectionName); } // if not found we will still use the default name, even if a name was provided if (clusterConnection == null) { clusterConnection = clusterManager.getDefaultConnection(acceptorConfig); } return clusterConnection; }
public synchronized void broadcastConnectors() throws Exception { HornetQBuffer buff = HornetQBuffers.dynamicBuffer(4096); buff.writeString(nodeID); buff.writeString(uniqueID); buff.writeInt(connectors.size()); for (TransportConfiguration tcConfig : connectors) { tcConfig.encode(buff); } byte[] data = buff.toByteBuffer().array(); DatagramPacket packet = new DatagramPacket(data, data.length, groupAddress, groupPort); socket.send(packet); }
/** * There's a case on ClusterConnections that we need to find an equivalent Connector * and we can't use a Netty Cluster Connection on an InVM ClusterConnection (inVM used on tests) * for that reason I need to test if the two instances of the TransportConfiguration are equivalent * while a test a connector against an acceptor * @param otherConfig * @return */ public boolean isEquivalent(TransportConfiguration otherConfig) { if (this.getFactoryClassName().equals(otherConfig.getFactoryClassName())) { return true; } else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) { return true; } else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) { return true; } else { return false; } }
public void setBackupConnector(final TransportConfiguration live, final TransportConfiguration backUp) { if (live.equals(connectorConfig) && backUp != null && !backUp.equals(connectorConfig)) { if (ClientSessionFactoryImpl.isDebug) { ClientSessionFactoryImpl.log.debug("Setting up backup config = " + backUp + " for live = " + live); } backupConfig = backUp; } else { if (ClientSessionFactoryImpl.isDebug) { ClientSessionFactoryImpl.log.debug("ClientSessionFactoryImpl received backup update for live/backup pair = " + live + " / " + backUp + " but it didn't belong to " + connectorConfig); } } }
Class<?> clazz = loader.loadClass(info.getFactoryClassName()); if (info.getParams() != null) Set<String> invalid = ConfigurationHelper.checkKeys(factory.getAllowableProperties(), info.getParams() .keySet()); info.getParams()); info.getParams(), new DelegatingBufferHandler(), manager, RemotingServiceImpl.log.warn("Error instantiating acceptor \"" + info.getFactoryClassName() + "\"", e);
public Map<String, Object> getParameters() { clearIO(); try { return configuration.getParams(); } finally { blockOnIO(); } }
@Override public void encodeRest(final HornetQBuffer buffer) { buffer.writeString(clusterUser); buffer.writeString(clusterPassword); buffer.writeBoolean(backupWantsFailBack); connector.encode(buffer); }
/** * There's a case on ClusterConnections that we need to find an equivalent Connector and we can't * use a Netty Cluster Connection on an InVM ClusterConnection (inVM used on tests) for that * reason I need to test if the two instances of the TransportConfiguration are equivalent while * a test a connector against an acceptor * @param otherConfig * @return {@code true} if the factory class names are equivalents */ public boolean isEquivalent(TransportConfiguration otherConfig) { if (this.getFactoryClassName().equals(otherConfig.getFactoryClassName())) { return true; } else if (this.getFactoryClassName().contains("Netty") && otherConfig.getFactoryClassName().contains("Netty")) { return true; } else if (this.getFactoryClassName().contains("InVM") && otherConfig.getFactoryClassName().contains("InVM")) { return true; } else { return false; } }
/** * Generates a {@link TransportConfiguration} to be use to connect to the * same target this is connect to * @return */ public TransportConfiguration getConnectorConfig() { if (configuration != null) { return new TransportConfiguration(NettyConnectorFactory.class.getName(), this.configuration); } else { return null; } }
@Override public void decodeRest(final HornetQBuffer buffer) { this.nodeID = buffer.readString(); this.backup = buffer.readBoolean(); this.currentEventID = buffer.readLong(); if (buffer.readBoolean()) { connector = new TransportConfiguration(); connector.decode(buffer); } if (buffer.readBoolean()) { backupConnector = new TransportConfiguration(); backupConnector.decode(buffer); } }
public static int getEncodeSize(TransportConfiguration config) { int size = BufferHelper.sizeOfNullableSimpleString(config.getName()) + BufferHelper.sizeOfSimpleString(config.getFactoryClassName()); size += DataConstants.SIZE_INT; // number of params for (Entry<String, Object> param : config.getParams().entrySet()) { size += BufferHelper.sizeOfSimpleString(param.getKey()); size += BufferHelper.sizeOfSimpleString(param.getValue().toString()); } return size; }
connectorFactory = instantiateConnectorFactory(connectorConfig.getFactoryClassName()); checkTransportKeys(connectorFactory, connectorConfig.getParams());
public Map<String, Object> getParameters() { clearIO(); try { return configuration.getParams(); } finally { blockOnIO(); } }
public synchronized void broadcastConnectors() throws Exception { HornetQBuffer buff = HornetQBuffers.dynamicBuffer(4096); buff.writeString(nodeManager.getNodeId().toString()); buff.writeString(uniqueID); buff.writeInt(connectors.size()); for (TransportConfiguration tcConfig : connectors) { tcConfig.encode(buff); } byte[] data = buff.toByteBuffer().array(); endpoint.broadcast(data); }
public String getFactoryClassName() { clearIO(); try { return configuration.getFactoryClassName(); } finally { blockOnIO(); } }