Refine search
public void sendWireFormat() throws IOException { try { WireFormatInfo info = wireFormat.getPreferedWireFormatInfo(); if (LOG.isDebugEnabled()) { LOG.debug("Sending: " + info); } sendWireFormat(info); } finally { wireInfoSentDownLatch.countDown(); } }
public OpenWireFormat copy() { OpenWireFormat answer = new OpenWireFormat(version); answer.stackTraceEnabled = stackTraceEnabled; answer.tcpNoDelayEnabled = tcpNoDelayEnabled; answer.cacheEnabled = cacheEnabled; answer.tightEncodingEnabled = tightEncodingEnabled; answer.sizePrefixDisabled = sizePrefixDisabled; answer.preferedWireFormatInfo = preferedWireFormatInfo; return answer; }
protected void looseMarshalCachedObject(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut) throws IOException { if (wireFormat.isCacheEnabled()) { Short index = wireFormat.getMarshallCacheIndex(o); dataOut.writeBoolean(index == null); if (index == null) { index = wireFormat.addToMarshallCache(o); dataOut.writeShort(index.shortValue()); wireFormat.looseMarshalNestedObject(o, dataOut); } else { dataOut.writeShort(index.shortValue()); } } else { wireFormat.looseMarshalNestedObject(o, dataOut); } }
protected int tightMarshalCachedObject1(OpenWireFormat wireFormat, DataStructure o, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { Short index = wireFormat.getMarshallCacheIndex(o); bs.writeBoolean(index == null); if (index == null) { int rc = wireFormat.tightMarshalNestedObject1(o, bs); wireFormat.addToMarshallCache(o); return 2 + rc; } else { return 2; } } else { return wireFormat.tightMarshalNestedObject1(o, bs); } }
protected DataStructure looseUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn) throws IOException { if (wireFormat.isCacheEnabled()) { if (dataIn.readBoolean()) { short index = dataIn.readShort(); DataStructure object = wireFormat.looseUnmarshalNestedObject(dataIn); wireFormat.setInUnmarshallCache(index, object); return object; } else { short index = dataIn.readShort(); return wireFormat.getFromUnmarshallCache(index); } } else { return wireFormat.looseUnmarshalNestedObject(dataIn); } }
protected void tightMarshalCachedObject2(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { Short index = wireFormat.getMarshallCacheIndex(o); if (bs.readBoolean()) { dataOut.writeShort(index.shortValue()); wireFormat.tightMarshalNestedObject2(o, dataOut, bs); } else { dataOut.writeShort(index.shortValue()); } } else { wireFormat.tightMarshalNestedObject2(o, dataOut, bs); } }
protected DataStructure tightUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { if (bs.readBoolean()) { short index = dataIn.readShort(); DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs); wireFormat.setInUnmarshallCache(index, object); return object; } else { short index = dataIn.readShort(); return wireFormat.getFromUnmarshallCache(index); } } else { return wireFormat.tightUnmarshalNestedObject(dataIn, bs); } }
wireFormat.marshal(command, new DataOutputStream(largeBuffer)); byte[] data = largeBuffer.toByteArray(); int size = data.length; if (wireFormat.isTightEncodingEnabled()) { bs = new BooleanStream(); bs.writeBoolean(true); // the partial data byte[] is if (!wireFormat.isSizePrefixDisabled()) {
wireFormat.renegotiateWireFormat(info); Socket socket = next.narrow(Socket.class); if (socket != null) { socket.setTcpNoDelay(wireFormat.isTcpNoDelayEnabled());
public Command read() throws IOException { Command answer = null; Endpoint from = null; synchronized (readLock) { while (true) { DatagramPacket datagram = createDatagramPacket(); channel.receive(datagram); // TODO could use a DataInput implementation that talks direct // to the byte[] to avoid object allocation receiveCounter++; DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(datagram.getData(), 0, datagram.getLength())); from = headerMarshaller.createEndpoint(datagram, dataIn); answer = (Command)wireFormat.unmarshal(dataIn); break; } } if (answer != null) { answer.setFrom(from); if (LOG.isDebugEnabled()) { LOG.debug("Channel: " + name + " about to process: " + answer); } } return answer; }
OpenWireFormat f = new OpenWireFormat(version); f.setMaxFrameSize(maxFrameSize); f.setPreferedWireFormatInfo(info); return f;
public void physicalSend(Command command) throws IOException { if (logger.isTraceEnabled()) { tracePhysicalSend(transportConnection, command); } try { final ByteSequence bytes = outWireFormat.marshal(command); final int bufferSize = bytes.length; final ActiveMQBuffer buffer = transportConnection.createTransportBuffer(bufferSize); buffer.writeBytes(bytes.data, bytes.offset, bufferSize); transportConnection.write(buffer, false, false); bufferSent(); } catch (IOException e) { throw e; } catch (Throwable t) { ActiveMQServerLogger.LOGGER.error("error sending", t); } }
final OpenWireFormat connectionWireFormat = serverTransport.getWireFormat().copy(); final UdpTransport transport = new UdpTransport(connectionWireFormat, address);
public WireFormat createWireFormat() { WireFormatInfo info = new WireFormatInfo(); info.setVersion(version); try { info.setStackTraceEnabled(stackTraceEnabled); info.setCacheEnabled(cacheEnabled); info.setTcpNoDelayEnabled(tcpNoDelayEnabled); info.setTightEncodingEnabled(tightEncodingEnabled); info.setSizePrefixDisabled(sizePrefixDisabled); info.setMaxInactivityDuration(maxInactivityDuration); info.setMaxInactivityDurationInitalDelay(maxInactivityDurationInitalDelay); info.setCacheSize(cacheSize); } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Could not configure WireFormatInfo"); ise.initCause(e); throw ise; } OpenWireFormat f = new OpenWireFormat(version); f.setPreferedWireFormatInfo(info); return f; }
@Override public Response processWireFormat(WireFormatInfo command) throws Exception { inWireFormat.renegotiateWireFormat(command); outWireFormat.renegotiateWireFormat(command); //throw back a brokerInfo here protocolManager.sendBrokerInfo(OpenWireConnection.this); protocolManager.configureInactivityParams(OpenWireConnection.this, command); return null; }
protected DataStructure looseUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn) throws IOException { if (wireFormat.isCacheEnabled()) { if (dataIn.readBoolean()) { short index = dataIn.readShort(); DataStructure object = wireFormat.looseUnmarshalNestedObject(dataIn); wireFormat.setInUnmarshallCache(index, object); return object; } else { short index = dataIn.readShort(); return wireFormat.getFromUnmarshallCache(index); } } else { return wireFormat.looseUnmarshalNestedObject(dataIn); } }
protected void tightMarshalCachedObject2(OpenWireFormat wireFormat, DataStructure o, DataOutput dataOut, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { Short index = wireFormat.getMarshallCacheIndex(o); if (bs.readBoolean()) { dataOut.writeShort(index.shortValue()); wireFormat.tightMarshalNestedObject2(o, dataOut, bs); } else { dataOut.writeShort(index.shortValue()); } } else { wireFormat.tightMarshalNestedObject2(o, dataOut, bs); } }
protected DataStructure tightUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { if (bs.readBoolean()) { short index = dataIn.readShort(); DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs); wireFormat.setInUnmarshallCache(index, object); return object; } else { short index = dataIn.readShort(); return wireFormat.getFromUnmarshallCache(index); } } else { return wireFormat.tightUnmarshalNestedObject(dataIn, bs); } }
protected int tightMarshalCachedObject1(OpenWireFormat wireFormat, DataStructure o, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { Short index = wireFormat.getMarshallCacheIndex(o); bs.writeBoolean(index == null); if (index == null) { int rc = wireFormat.tightMarshalNestedObject1(o, bs); wireFormat.addToMarshallCache(o); return 2 + rc; } else { return 2; } } else { return wireFormat.tightMarshalNestedObject1(o, bs); } }
wireFormat.marshal(command, dataOut); if (wireFormat.isTightEncodingEnabled()) { bs = new BooleanStream(); bs.writeBoolean(true); // the partial data byte[] is if (!wireFormat.isSizePrefixDisabled()) {