public static TransportConfiguration decode(HornetQBuffer buffer) { String name = BufferHelper.readNullableSimpleStringAsString(buffer); String factoryClassName = buffer.readSimpleString().toString(); int paramSize = buffer.readInt(); Map<String, Object> params = new HashMap<String, Object>(); for (int i = 0; i < paramSize; i++) { String key = buffer.readSimpleString().toString(); String value = buffer.readSimpleString().toString(); params.put(key, value); } TransportConfiguration config = new TransportConfiguration(factoryClassName, params, name); return config; }
@Override public void decodeRest(final HornetQBuffer buffer) { synchronizationIsFinished = buffer.readBoolean(); allowsAutoFailBack = buffer.readBoolean(); nodeID = buffer.readString(); if (synchronizationIsFinished) { return; } dataType = SyncDataType.getDataType(buffer.readByte()); int length = buffer.readInt(); ids = new long[length]; for (int i = 0; i < length; i++) { ids[i] = buffer.readLong(); } }
// Decode from journal or paging public void decode(final HornetQBuffer buff) { int start = buff.readerIndex(); endOfBodyPosition = buff.readInt(); endOfMessagePosition = buff.getInt(endOfBodyPosition - BUFFER_HEADER_SPACE + start); int length = endOfMessagePosition - BUFFER_HEADER_SPACE; buffer.setIndex(0, BUFFER_HEADER_SPACE); buffer.writeBytes(buff, start, length); decode(); buff.readerIndex(start + length); }
public static List<Pair<TransportConfiguration, TransportConfiguration>> decodeConfigs( HornetQBuffer buffer) { int size = buffer.readInt(); List<Pair<TransportConfiguration, TransportConfiguration>> configs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>(size); for (int i = 0; i < size; i++) { TransportConfiguration live = decode(buffer); boolean hasBackup = buffer.readBoolean(); TransportConfiguration backup = null; if (hasBackup) { backup = decode(buffer); } configs.add(new Pair<TransportConfiguration, TransportConfiguration>(live, backup)); } return configs; }
public synchronized List<PagedMessage> read(StorageManager storage) throws Exception { if (isDebug) { HornetQServerLogger.LOGGER.debug( "reading page " + this.pageId + " on address = " + storeName); } if (!file.isOpen()) { throw HornetQMessageBundle.BUNDLE.invalidPageIO(); } ArrayList<PagedMessage> messages = new ArrayList<PagedMessage>(); size.set((int) file.size()); // Using direct buffer, as described on https://jira.jboss.org/browse/HORNETQ-467 ByteBuffer directBuffer = storage.allocateDirectBuffer((int) file.size()); try { file.position(0); file.read(directBuffer); directBuffer.rewind(); HornetQBuffer fileBuffer = HornetQBuffers.wrappedBuffer(directBuffer); fileBuffer.writerIndex(fileBuffer.capacity()); while (fileBuffer.readable()) { final int position = fileBuffer.readerIndex(); byte byteRead = fileBuffer.readByte(); if (byteRead == Page.START_BYTE) { if (fileBuffer.readerIndex() + DataConstants.SIZE_INT < fileBuffer.capacity()) { int messageSize = fileBuffer.readInt(); int oldPos = fileBuffer.readerIndex(); if (fileBuffer.readerIndex() + messageSize < fileBuffer.capacity() && fileBuffer.getByte(oldPos + messageSize) == Page.END_BYTE) { PagedMessage msg = new PagedMessageImpl(); msg.decode(fileBuffer); byte b = fileBuffer.readByte(); if (b != Page.END_BYTE) { // Sanity Check: This would only happen if there is a bug on decode or any internal // code, as // this // constraint was already checked throw new IllegalStateException( "Internal error, it wasn't possible to locate END_BYTE " + b); } msg.initMessage(storage); if (isTrace) { HornetQServerLogger.LOGGER.trace( "Reading message " + msg + " on pageId=" + this.pageId + " for address=" + storeName); } messages.add(msg); } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } } else { markFileAsSuspect(file.getFileName(), position, messages.size()); break; } } } finally { storage.freeDirectBuffer(directBuffer); } numberOfMessages.set(messages.size()); return messages; }
@Override public void decodeRest(final HornetQBuffer buffer) { timeoutSeconds = buffer.readInt(); }
@Override public void decodeRest(final HornetQBuffer buffer) { credits = buffer.readInt(); address = buffer.readSimpleString(); }