private Location checkpointProducerAudit() throws IOException { if (metadata.producerSequenceIdTracker == null || metadata.producerSequenceIdTracker.modified()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(baos); oout.writeObject(metadata.producerSequenceIdTracker); oout.flush(); oout.close(); // using completion callback allows a disk sync to be avoided when enableJournalDiskSyncs = false Location location = store(new KahaProducerAuditCommand().setAudit(new Buffer(baos.toByteArray())), nullCompletionCallback); try { location.getLatch().await(); if (location.getException().get() != null) { throw location.getException().get(); } } catch (InterruptedException e) { throw new InterruptedIOException(e.toString()); } return location; } return metadata.producerSequenceIdTrackerLocation; }
private boolean recoverProducerAudit() throws IOException { boolean requiresReplay = true; if (metadata.producerSequenceIdTrackerLocation != null) { try { KahaProducerAuditCommand audit = (KahaProducerAuditCommand) load(metadata.producerSequenceIdTrackerLocation); ObjectInputStream objectIn = new ObjectInputStream(audit.getAudit().newInput()); int maxNumProducers = getMaxFailoverProducersToTrack(); int maxAuditDepth = getFailoverProducersAuditDepth(); metadata.producerSequenceIdTracker = (ActiveMQMessageAuditNoSync) objectIn.readObject(); metadata.producerSequenceIdTracker.setAuditDepth(maxAuditDepth); metadata.producerSequenceIdTracker.setMaximumNumberOfProducersToTrack(maxNumProducers); requiresReplay = false; } catch (Exception e) { LOG.warn("Cannot recover message audit", e); } } // got no audit stored so got to recreate via replay from start of the journal return requiresReplay; }
public static KahaProducerAuditCommand parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException { return new KahaProducerAuditCommand().mergeFramed(data).checktInitialized(); }
public static KahaProducerAuditCommand parseUnframed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException { return new KahaProducerAuditCommand().mergeUnframed(data).checktInitialized(); }
public KahaProducerAuditCommand clone() { return new KahaProducerAuditCommand().mergeFrom(this); }
public java.util.ArrayList<String> missingFields() { java.util.ArrayList<String> missingFields = super.missingFields(); if( !hasAudit() ) { missingFields.add("audit"); } return missingFields; }
public boolean equals(Object obj) { if( obj==this ) return true; if( obj==null || obj.getClass()!=KahaProducerAuditCommand.class ) return false; return equals((KahaProducerAuditCommand)obj); }
public void clear() { super.clear(); clearAudit(); }
public KahaProducerAuditCommand mergeUnframed(org.apache.activemq.protobuf.CodedInputStream input) throws java.io.IOException { while (true) { int tag = input.readTag(); if ((tag & 0x07) == 4) { return this; } switch (tag) { case 0: return this; default: { break; } case 10: setAudit(input.readBytes()); break; } } } public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException {
public org.apache.activemq.protobuf.Message createMessage() { switch (this) { case KAHA_TRACE_COMMAND: return new KahaTraceCommand(); case KAHA_ADD_MESSAGE_COMMAND: return new KahaAddMessageCommand(); case KAHA_REMOVE_MESSAGE_COMMAND: return new KahaRemoveMessageCommand(); case KAHA_PREPARE_COMMAND: return new KahaPrepareCommand(); case KAHA_COMMIT_COMMAND: return new KahaCommitCommand(); case KAHA_ROLLBACK_COMMAND: return new KahaRollbackCommand(); case KAHA_REMOVE_DESTINATION_COMMAND: return new KahaRemoveDestinationCommand(); case KAHA_SUBSCRIPTION_COMMAND: return new KahaSubscriptionCommand(); case KAHA_PRODUCER_AUDIT_COMMAND: return new KahaProducerAuditCommand(); default: return null; } }
public static KahaProducerAuditCommand parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException { return new KahaProducerAuditCommand().mergeFramed(data).checktInitialized(); }
public static KahaProducerAuditCommand parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException { return new KahaProducerAuditCommand().mergeUnframed(data).checktInitialized(); }
public KahaProducerAuditCommand clone() { return new KahaProducerAuditCommand().mergeFrom(this); }
public java.util.ArrayList<String> missingFields() { java.util.ArrayList<String> missingFields = super.missingFields(); if( !hasAudit() ) { missingFields.add("audit"); } return missingFields; }
public boolean equals(Object obj) { if( obj==this ) return true; if( obj==null || obj.getClass()!=KahaProducerAuditCommand.class ) return false; return equals((KahaProducerAuditCommand)obj); }
public void clear() { super.clear(); clearAudit(); }