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; }
answer = (Command)wireFormat.unmarshal(dataIn); break;
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
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; }
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; }
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; }
answer = (Command)wireFormat.unmarshal(dataIn); break;
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; }
answer = (Command)wireFormat.unmarshal(dataIn); break;
answer = (Command)wireFormat.unmarshal(dataIn); break;
answer = (Command)wireFormat.unmarshal(dataIn); break;
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
Command command = (Command) inWireFormat.unmarshal(buffer);
Object object = wireFormat.unmarshal(dataIn); transport.doConsume(object); readStart = len;
Object object = wireFormat.unmarshal(dataIn); transport.doConsume(object); readStart = len;