/** * 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; } }
@Override public boolean allInVM() { for (TransportConfiguration config : getStaticTransportConfigurations()) { if (!config.getFactoryClassName().contains("InVMConnectorFactory")) { return false; } } return true; }
private void updateTransportConfiguration(TransportConfiguration connector) { if (connector != null) { String factoryClassName = connector.getFactoryClassName(); if ("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory".equals(factoryClassName)) { connector.setFactoryClassName(NettyConnectorFactory.class.getName()); } } }
public static boolean isSameHost(TransportConfiguration tc1, TransportConfiguration tc2) { if (NettyConnectorFactory.class.getName().equals(tc1.getFactoryClassName())) { String host1 = tc1.getParams().get("host") != null ? tc1.getParams().get("host").toString() : TransportConstants.DEFAULT_HOST; String host2 = tc2.getParams().get("host") != null ? tc2.getParams().get("host").toString() : TransportConstants.DEFAULT_HOST; String port1 = String.valueOf(tc1.getParams().get("port") != null ? tc1.getParams().get("port") : TransportConstants.DEFAULT_PORT); String port2 = String.valueOf(tc2.getParams().get("port") != null ? tc2.getParams().get("port") : TransportConstants.DEFAULT_PORT); return host1.equals(host2) && port1.equals(port2); } else if ("org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory".equals(tc1.getFactoryClassName())) { String serverId1 = tc1.getParams().get("serverId") != null ? tc1.getParams().get("serverId").toString() : "0"; String serverId2 = tc2.getParams().get("serverId") != null ? tc2.getParams().get("serverId").toString() : "0"; return serverId1.equals(serverId2); } return false; }
/** * Replaces class name and parameter names to HornetQ values. */ private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); } return tc; }
continue; if (NettyConnectorFactory.class.getName().equals(cfg.getFactoryClassName())) { if (configuration.get(TransportConstants.PORT_PROP_NAME).equals(cfg.getParams().get(TransportConstants.PORT_PROP_NAME))) {
/** * Adapt the transport configuration by replacing the factoryClassName corresponding to an HornetQ's NettyConnectorFactory * by the Artemis-based implementation. */ @Override public TransportConfiguration adaptTransportConfiguration(TransportConfiguration tc) { if (tc == null) { return null; } String factoryClassName = tc.getFactoryClassName(); if (factoryClassName.equals("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory")) { factoryClassName = NettyConnectorFactory.class.getName(); } TransportConfiguration newConfig = new TransportConfiguration(factoryClassName, tc.getParams(), tc.getName(), tc.getExtraParams()); return newConfig; }
ConnectorFactory backupConnectorFactory = instantiateConnectorFactory(backupConfig.getFactoryClassName()); ConnectorFactory lastConnectorFactory = instantiateConnectorFactory(connectorConfig.getFactoryClassName());
connectorFactory = instantiateConnectorFactory(connectorConfig.getFactoryClassName());
@Override public boolean allInVM() { for (TransportConfiguration config : getStaticTransportConfigurations()) { if (!config.getFactoryClassName().contains("InVMConnectorFactory")) { return false; } } return true; }
@Override public boolean allInVM() { for (TransportConfiguration config : getStaticTransportConfigurations()) { if (!config.getFactoryClassName().contains("InVMConnectorFactory")) { return false; } } return true; }
private void updateTransportConfiguration(TransportConfiguration connector) { if (connector != null) { String factoryClassName = connector.getFactoryClassName(); if ("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory".equals(factoryClassName)) { connector.setFactoryClassName(NettyConnectorFactory.class.getName()); } } }
@Override public boolean allInVM() { for (TransportConfiguration config : getStaticTransportConfigurations()) { if (!config.getFactoryClassName().contains("InVMConnectorFactory")) { return false; } } return true; }
/** * Replaces class name and parameter names to HornetQ values. */ private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); } return tc; }
/** * Replaces class name and parameter names to HornetQ values. */ private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); } return tc; }
/** * Replaces class name and parameter names to HornetQ values. */ private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); } return tc; }
/** * Replaces class name and parameter names to HornetQ values. */ private static TransportConfiguration convertTransport(TransportConfiguration tc) { if (tc != null) { String className = tc.getFactoryClassName().replace("org.apache.activemq.artemis", "org.hornetq").replace("ActiveMQ", "HornetQ"); return new TransportConfiguration(className, convertParameters(tc.getParams()), tc.getName()); } return tc; }
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; }
public static void encode(ActiveMQBuffer 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()); } }
private static void assertEquivalent(TransportConfiguration expected, TransportConfiguration actual) { assertEquals(expected.getFactoryClassName(), actual.getFactoryClassName()); assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getParams().size(), actual.getParams().size()); for (Map.Entry<String, Object> entry : expected.getParams().entrySet()) { String key = entry.getKey(); assertEquals(expected.getParams().get(key).toString(), actual.getParams().get(key).toString()); } } // Package protected ---------------------------------------------