@Override public boolean isProtocol(byte[] value) { if (value.length < 8) { throw new IllegalArgumentException("Protocol header length changed " + value.length); } int start = !((OpenWireFormat)wireFormatFactory.createWireFormat()).isSizePrefixDisabled() ? 4 : 0; int j = 0; // type if (value[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) { return false; } start++; WireFormatInfo info = new WireFormatInfo(); final byte[] magic = info.getMagic(); int remainingLen = value.length - start; int useLen = remainingLen > magic.length ? magic.length : remainingLen; useLen += start; // magic for (int i = start; i < useLen; i++) { if (value[i] != magic[j]) { return false; } j++; } return true; }
@Override public boolean isProtocol(byte[] value) { if (value.length < 8) { throw new IllegalArgumentException("Protocol header length changed " + value.length); } int start = !((OpenWireFormat)wireFormatFactory.createWireFormat()).isSizePrefixDisabled() ? 4 : 0; int j = 0; // type if (value[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) { return false; } start++; WireFormatInfo info = new WireFormatInfo(); final byte[] magic = info.getMagic(); int remainingLen = value.length - start; int useLen = remainingLen > magic.length ? magic.length : remainingLen; useLen += start; // magic for (int i = start; i < useLen; i++) { if (value[i] != magic[j]) { return false; } j++; } return true; }
@Override public boolean isProtocol(byte[] value) { if (value.length < 8) { throw new IllegalArgumentException("Protocol header length changed " + value.length); } int start = !((OpenWireFormat)wireFormatFactory.createWireFormat()).isSizePrefixDisabled() ? 4 : 0; int j = 0; // type if (value[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) { return false; } start++; WireFormatInfo info = new WireFormatInfo(); final byte[] magic = info.getMagic(); int remainingLen = value.length - start; int useLen = remainingLen > magic.length ? magic.length : remainingLen; useLen += start; // magic for (int i = start; i < useLen; i++) { if (value[i] != magic[j]) { return false; } j++; } return true; }
@Override public boolean isProtocol(byte[] value) { if (value.length < 8) { throw new IllegalArgumentException("Protocol header length changed " + value.length); } int start = !((OpenWireFormat)wireFormatFactory.createWireFormat()).isSizePrefixDisabled() ? 4 : 0; int j = 0; // type if (value[start] != WireFormatInfo.DATA_STRUCTURE_TYPE) { return false; } start++; WireFormatInfo info = new WireFormatInfo(); final byte[] magic = info.getMagic(); int remainingLen = value.length - start; int useLen = remainingLen > magic.length ? magic.length : remainingLen; useLen += start; // magic for (int i = start; i < useLen; i++) { if (value[i] != magic[j]) { return false; } j++; } return true; }
@Override public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) { OpenWireFormat wf = (OpenWireFormat) wireFactory.createWireFormat(); OpenWireConnection owConn = new OpenWireConnection(connection, server, server.getExecutorFactory().getExecutor(), this, wf); owConn.sendHandshake(); //first we setup ttl to -1 //then when negotiation, we handle real ttl and delay ConnectionEntry entry = new ConnectionEntry(owConn, null, System.currentTimeMillis(), -1); owConn.setConnectionEntry(entry); return entry; }
public OpenWireProtocolManager(OpenWireProtocolManagerFactory factory, ActiveMQServer server) { this.factory = factory; this.server = server; this.wireFactory = new OpenWireFormatFactory(); // preferred prop, should be done via config wireFactory.setCacheEnabled(false); advisoryProducerId.setConnectionId(ID_GENERATOR.generateId()); scheduledPool = server.getScheduledPool(); this.wireFormat = (OpenWireFormat) wireFactory.createWireFormat(); final ClusterManager clusterManager = this.server.getClusterManager(); ClusterConnection cc = clusterManager.getDefaultConnection(null); if (cc != null) { cc.addClusterTopologyListener(this); } }