Java Code Examples for org.apache.activemq.artemis.api.core.SimpleString#sizeofString()

The following examples show how to use org.apache.activemq.artemis.api.core.SimpleString#sizeofString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypedProperties.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private synchronized void doPutValue(final SimpleString key, final PropertyValue value) {
   if (!internalProperties && internalPropertyPredicate != null && internalPropertyPredicate.test(key)) {
      internalProperties = true;
   }

   if (properties == null) {
      properties = new HashMap<>();
   }

   PropertyValue oldValue = properties.put(key, value);
   if (oldValue != null) {
      size += value.encodeSize() - oldValue.encodeSize();
   } else {
      size += SimpleString.sizeofString(key) + value.encodeSize();
   }
}
 
Example 2
Source File: PersistentQueueBindingEncoding.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofString(name) + SimpleString.sizeofString(address) +
      SimpleString.sizeofNullableString(filterString) + DataConstants.SIZE_BOOLEAN +
      SimpleString.sizeofNullableString(createMetadata()) +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BYTE +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_LONG +
      SimpleString.sizeofNullableString(lastValueKey) +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_INT +
      DataConstants.SIZE_BOOLEAN +
      DataConstants.SIZE_LONG +
      DataConstants.SIZE_LONG +
      SimpleString.sizeofNullableString(groupFirstKey) +
      DataConstants.SIZE_LONG +
      DataConstants.SIZE_BOOLEAN;
}
 
Example 3
Source File: TypedProperties.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private synchronized Object doRemoveProperty(final SimpleString key) {
   if (properties == null) {
      return null;
   }

   PropertyValue val = properties.remove(key);
   if (val == null) {
      return null;
   } else {
      size -= SimpleString.sizeofString(key) + val.encodeSize();
      return val.getValue();
   }
}
 
Example 4
Source File: ReplicationSyncFileMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int expectedEncodeSize() {
   int size = PACKET_HEADERS_SIZE +
              DataConstants.SIZE_LONG; // buffer.writeLong(fileId);

   if (fileId == -1)
      return size;

   size += DataConstants.SIZE_BYTE; // buffer.writeByte(fileType.code);
   switch (fileType) {
      case JOURNAL: {
         size += DataConstants.SIZE_BYTE; // buffer.writeByte(journalType.typeByte);
         break;
      }
      case PAGE: {
         size += SimpleString.sizeofString(pageStoreName);
         break;
      }
      case LARGE_MESSAGE:
      default:
         // no-op
   }

   size += DataConstants.SIZE_INT; // buffer.writeInt(dataSize);

   if (dataSize > 0) {
      size += byteBuffer.writerIndex(); // buffer.writeBytes(byteBuffer, 0, byteBuffer.writerIndex());
   }

   return size;
}
 
Example 5
Source File: ReplicationPageEventMessage.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int expectedEncodeSize() {
   return PACKET_HEADERS_SIZE +
          SimpleString.sizeofString(storeName) + // buffer.writeSimpleString(storeName);
          DataConstants.SIZE_INT + //  buffer.writeInt(pageNumber);
          DataConstants.SIZE_BOOLEAN; // buffer.writeBoolean(isDelete);
}
 
Example 6
Source File: PersistentAddressBindingEncoding.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofString(name) +
      DataConstants.SIZE_INT +
      (DataConstants.SIZE_BYTE * routingTypes.size()) +
      DataConstants.SIZE_BOOLEAN;
}
 
Example 7
Source File: TypedProperties.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int encodeSize() {
   return DataConstants.SIZE_BYTE + SimpleString.sizeofString(val);
}
 
Example 8
Source File: GroupingEncoding.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofString(groupId) + SimpleString.sizeofString(clusterName);
}
 
Example 9
Source File: DuplicateIDEncoding.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public int getEncodeSize() {
   return SimpleString.sizeofString(address) + DataConstants.SIZE_INT + duplID.length;
}