protected Object readCommand() throws IOException { return wireFormat.unmarshal(dataIn); }
protected WireFormat createWireFormat(Map<String, String> options) throws IOException { WireFormatFactory factory = createWireFormatFactory(options); WireFormat format = factory.createWireFormat(); return format; }
protected ByteSequence getByteSequence(Message message) throws IOException { org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(message); return new ByteSequence(packet.data, packet.offset, packet.length); }
@Override protected void configureMetadata() { if (brokerService != null) { metadata.openwireVersion = brokerService.getStoreOpenWireVersion(); wireFormat.setVersion(metadata.openwireVersion); if (LOG.isDebugEnabled()) { LOG.debug("Store OpenWire version configured as: {}", metadata.openwireVersion); } } }
public ByteSequence marshal(Object command) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream ds = new DataOutputStream(baos); marshal(command, ds); ds.close(); return baos.toByteSequence(); }
public Object unmarshal(ByteSequence packet) throws IOException { return unmarshal(new DataInputStream(new ByteArrayInputStream(packet))); }
protected Message getMessage(ByteSequence bs) throws IOException { org.apache.activemq.util.ByteSequence packet = new org.apache.activemq.util.ByteSequence(bs.getData(), bs .getOffset(), bs.getLength()); return (Message) this.wireFormat.unmarshal(packet); }
/** * A one way asynchronous send */ @Override public void oneway(Object command) throws IOException { checkStarted(); wireFormat.marshal(command, dataOut); dataOut.flush(); }
protected WireFormat createWireFormat() { return getWireFormatFactory().createWireFormat(); }
@Override public void load() throws IOException { if( brokerService!=null ) { wireFormat.setVersion(brokerService.getStoreOpenWireVersion()); } super.load(); } @Override
/** * @param location * @return * @throws IOException */ public DataStructure readCommand(RecordLocation location) throws IOException { try { Packet packet = journal.read(location); return (DataStructure)wireFormat.unmarshal(toByteSequence(packet)); } catch (InvalidRecordLocationException e) { throw createReadException(location, e); } catch (IOException e) { throw createReadException(location, e); } }
@Override public void addMessage(ConnectionContext context, Message message) throws IOException { KahaAddMessageCommand command = new KahaAddMessageCommand(); command.setDestination(dest); command.setMessageId(message.getMessageId().toProducerKey()); processAdd(command, message.getTransactionId(), wireFormat.marshal(message)); }
protected TransportInfo configureTransport(final TcpTransportServer server, final Socket socket) throws Exception { WireFormat format = wireFormatFactory.createWireFormat(); Transport transport = createTransport(socket, format); return new TransportInfo(format, transport, transportFactory); }
@Override public void doStart() throws Exception { if( brokerService!=null ) { wireFormat.setVersion(brokerService.getStoreOpenWireVersion()); } // Cleanup the db periodically. if (cleanupPeriod > 0) { cleanupTicket = getScheduledThreadPoolExecutor().scheduleWithFixedDelay(new Runnable() { @Override public void run() { cleanup(); } }, 0, cleanupPeriod, TimeUnit.MILLISECONDS); } createMessageAudit(); }
@Override public boolean recoverMessage(long sequenceId, byte[] data) throws Exception { Message msg = (Message)wireFormat.unmarshal(new ByteSequence(data)); msg.getMessageId().setBrokerSequenceId(sequenceId); return listener.recoverMessage(msg); }
@Override public void addSubscription(SubscriptionInfo subscriptionInfo, boolean retroactive) throws IOException { String subscriptionKey = subscriptionKey(subscriptionInfo.getClientId(), subscriptionInfo.getSubscriptionName()); KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setRetroactive(retroactive); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(subscriptionInfo); command.setSubscriptionInfo(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); process(command); }
@Override public boolean recoverMessage(long sequenceId, byte[] data) throws Exception { if (delegate.hasSpace() && recoveredCount < maxMessages) { Message msg = (Message) wireFormat.unmarshal(new ByteSequence(data)); msg.getMessageId().setBrokerSequenceId(sequenceId); lastRecovered.recovered = sequenceId; if (delegate.recoverMessage(msg)) { recoveredCount++; return true; } } return false; }
@Override public boolean recoverMessage(long sequenceId, byte[] data) throws Exception { Message msg = (Message)wireFormat.unmarshal(new ByteSequence(data)); msg.getMessageId().setBrokerSequenceId(sequenceId); msg.getMessageId().setFutureOrSequenceLong(sequenceId); msg.getMessageId().setEntryLocator(sequenceId); listener.recoverMessage(msg); trackLastRecovered(sequenceId, msg.getPriority()); return true; }