io.atomix.utils.serializer.Namespace Java Examples

The following examples show how to use io.atomix.utils.serializer.Namespace. 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: AbstractAtomicMapService.java    From atomix with Apache License 2.0 6 votes vote down vote up
public AbstractAtomicMapService(PrimitiveType primitiveType) {
  super(primitiveType, AtomicMapClient.class);
  serializer = Serializer.using(Namespace.builder()
      .register(primitiveType.namespace())
      .register(SessionId.class)
      .register(TransactionId.class)
      .register(TransactionScope.class)
      .register(MapEntryValue.class)
      .register(MapEntryValue.Type.class)
      .register(new HashMap().keySet().getClass())
      .register(DefaultIterator.class)
      .register(LockContext.class)
      .register(LockHolder.class)
      .build());
  map = createMap();
}
 
Example #2
Source File: AtomicDocumentTreeType.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(LinkedHashMap.class)
      .register(TransactionId.class)
      .register(TransactionLog.class)
      .register(PrepareResult.class)
      .register(CommitResult.class)
      .register(RollbackResult.class)
      .register(NodeUpdate.class)
      .register(NodeUpdate.Type.class)
      .register(DocumentPath.class)
      .register(Match.class)
      .register(Versioned.class)
      .register(DocumentTreeResult.class)
      .register(DocumentTreeResult.Status.class)
      .register(DocumentTreeEvent.class)
      .register(DocumentTreeEvent.Type.class)
      .build();
}
 
Example #3
Source File: AtomicMapType.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(TransactionId.class)
      .register(TransactionLog.class)
      .register(MapUpdate.class)
      .register(MapUpdate.Type.class)
      .register(PrepareResult.class)
      .register(CommitResult.class)
      .register(RollbackResult.class)
      .register(MapEntryUpdateResult.class)
      .register(MapEntryUpdateResult.Status.class)
      .register(Versioned.class)
      .register(AtomicMapEvent.class)
      .register(AtomicMapEvent.Type.class)
      .register(IteratorBatch.class)
      .register(Versioned.class)
      .register(byte[].class)
      .build();
}
 
Example #4
Source File: DistributedSetType.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .register(TransactionId.class)
      .register(TransactionLog.class)
      .register(SetUpdate.class)
      .register(SetUpdate.Type.class)
      .register(PrepareResult.class)
      .register(CommitResult.class)
      .register(RollbackResult.class)
      .build();
}
 
Example #5
Source File: DistributedSortedSetType.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .register(TransactionId.class)
      .register(TransactionLog.class)
      .register(SetUpdate.class)
      .register(SetUpdate.Type.class)
      .register(PrepareResult.class)
      .register(CommitResult.class)
      .register(RollbackResult.class)
      .build();
}
 
Example #6
Source File: DistributedNavigableSetType.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .register(TransactionId.class)
      .register(TransactionLog.class)
      .register(SetUpdate.class)
      .register(SetUpdate.Type.class)
      .register(PrepareResult.class)
      .register(CommitResult.class)
      .register(RollbackResult.class)
      .build();
}
 
Example #7
Source File: SegmentedJournal.java    From atomix with Apache License 2.0 6 votes vote down vote up
public SegmentedJournal(
    String name,
    StorageLevel storageLevel,
    File directory,
    Namespace namespace,
    int maxSegmentSize,
    int maxEntrySize,
    int maxEntriesPerSegment,
    double indexDensity,
    boolean flushOnCommit) {
  this.name = checkNotNull(name, "name cannot be null");
  this.storageLevel = checkNotNull(storageLevel, "storageLevel cannot be null");
  this.directory = checkNotNull(directory, "directory cannot be null");
  this.namespace = checkNotNull(namespace, "namespace cannot be null");
  this.maxSegmentSize = maxSegmentSize;
  this.maxEntrySize = maxEntrySize;
  this.maxEntriesPerSegment = maxEntriesPerSegment;
  this.indexDensity = indexDensity;
  this.flushOnCommit = flushOnCommit;
  open();
  this.writer = openWriter();
}
 
Example #8
Source File: FileChannelJournalSegmentWriter.java    From atomix with Apache License 2.0 6 votes vote down vote up
FileChannelJournalSegmentWriter(
    FileChannel channel,
    JournalSegment segment,
    int maxEntrySize,
    JournalIndex index,
    Namespace namespace) {
  this.channel = channel;
  this.segment = segment;
  this.maxEntrySize = maxEntrySize;
  this.index = index;
  this.memory = ByteBuffer.allocate((maxEntrySize + Integer.BYTES + Integer.BYTES) * 2);
  memory.limit(0);
  this.namespace = namespace;
  this.firstIndex = segment.index();
  reset(0);
}
 
Example #9
Source File: LeaderElectorType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Leadership.class)
      .register(Leader.class)
      .build();
}
 
Example #10
Source File: AtomicCounterMapBuilder.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
  if (serializer == null) {
    NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
    if (namespaceConfig == null) {
      namespaceConfig = new NamespaceConfig();
    }

    SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
    serializerBuilder.withNamespace(new Namespace(namespaceConfig));

    if (config.isRegistrationRequired()) {
      serializerBuilder.withRegistrationRequired();
    }
    if (config.isCompatibleSerialization()) {
      serializerBuilder.withCompatibleSerialization();
    }

    if (config.getKeyType() != null) {
      serializerBuilder.addType(config.getKeyType());
    }
    if (!config.getExtraTypes().isEmpty()) {
      serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
    }

    serializer = serializerBuilder.build();
  }
  return serializer;
}
 
Example #11
Source File: AtomicDocumentTreeBuilder.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
  if (serializer == null) {
    NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
    if (namespaceConfig == null) {
      namespaceConfig = new NamespaceConfig();
    }

    SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
    serializerBuilder.withNamespace(new Namespace(namespaceConfig));

    if (config.isRegistrationRequired()) {
      serializerBuilder.withRegistrationRequired();
    }
    if (config.isCompatibleSerialization()) {
      serializerBuilder.withCompatibleSerialization();
    }

    if (config.getNodeType() != null) {
      serializerBuilder.addType(config.getNodeType());
    }
    if (!config.getExtraTypes().isEmpty()) {
      serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
    }

    serializer = serializerBuilder.build();
  }
  return serializer;
}
 
Example #12
Source File: DefaultDistributedNavigableSetService.java    From atomix with Apache License 2.0 5 votes vote down vote up
public DefaultDistributedNavigableSetService() {
  super(DistributedNavigableSetType.instance(), new ConcurrentSkipListSet<>());
  this.serializer = Serializer.using(Namespace.builder()
      .register(DistributedNavigableSetType.instance().namespace())
      .register(SessionId.class)
      .register(IteratorContext.class)
      .register(SubSetIteratorContext.class)
      .register(DescendingIteratorContext.class)
      .register(DescendingSubSetIteratorContext.class)
      .build());
}
 
Example #13
Source File: DistributedListType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .build();
}
 
Example #14
Source File: DefaultDistributedListService.java    From atomix with Apache License 2.0 5 votes vote down vote up
public DefaultDistributedListService() {
  super(DistributedListType.instance(), Collections.synchronizedList(new ArrayList<>()));
  this.serializer = Serializer.using(Namespace.builder()
      .register(DistributedListType.instance().namespace())
      .register(SessionId.class)
      .register(DefaultDistributedCollectionService.IteratorContext.class)
      .register(IteratorContext.class)
      .build());
}
 
Example #15
Source File: ValueBuilder.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
  if (serializer == null) {
    NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
    if (namespaceConfig == null) {
      namespaceConfig = new NamespaceConfig();
    }

    SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
    serializerBuilder.withNamespace(new Namespace(namespaceConfig));

    if (config.isRegistrationRequired()) {
      serializerBuilder.withRegistrationRequired();
    }
    if (config.isCompatibleSerialization()) {
      serializerBuilder.withCompatibleSerialization();
    }

    if (config.getValueType() != null) {
      serializerBuilder.addType(config.getValueType());
    }
    if (!config.getExtraTypes().isEmpty()) {
      serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
    }

    serializer = serializerBuilder.build();
  }
  return serializer;
}
 
Example #16
Source File: DistributedCyclicBarrierType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(CyclicBarrierResult.class)
      .register(CyclicBarrierResult.Status.class)
      .build();
}
 
Example #17
Source File: AbstractAtomicNavigableMapService.java    From atomix with Apache License 2.0 5 votes vote down vote up
public AbstractAtomicNavigableMapService(PrimitiveType primitiveType) {
  super(primitiveType);
  serializer = Serializer.using(Namespace.builder()
      .register(AtomicNavigableMapType.instance().namespace())
      .register(SessionId.class)
      .register(TransactionId.class)
      .register(TransactionScope.class)
      .register(MapEntryValue.class)
      .register(MapEntryValue.Type.class)
      .register(new HashMap().keySet().getClass())
      .register(DefaultIterator.class)
      .register(AscendingIterator.class)
      .register(DescendingIterator.class)
      .build());
}
 
Example #18
Source File: LeaderElectionType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Leadership.class)
      .register(Leader.class)
      .build();
}
 
Example #19
Source File: AtomicSemaphoreType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(Namespaces.BASIC)
      .register(AtomicSemaphoreServiceConfig.class)
      .register(Version.class)
      .register(QueueStatus.class)
      .build();
}
 
Example #20
Source File: DistributedSemaphoreType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(Namespaces.BASIC)
      .register(AtomicSemaphoreServiceConfig.class)
      .register(Version.class)
      .register(QueueStatus.class)
      .build();
}
 
Example #21
Source File: DistributedQueueType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .build();
}
 
Example #22
Source File: DistributedCollectionBuilder.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
  if (serializer == null) {
    NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
    if (namespaceConfig == null) {
      namespaceConfig = new NamespaceConfig();
    }

    SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
    serializerBuilder.withNamespace(new Namespace(namespaceConfig));

    if (config.isRegistrationRequired()) {
      serializerBuilder.withRegistrationRequired();
    }
    if (config.isCompatibleSerialization()) {
      serializerBuilder.withCompatibleSerialization();
    }

    if (config.getElementType() != null) {
      serializerBuilder.addType(config.getElementType());
    }
    if (!config.getExtraTypes().isEmpty()) {
      serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
    }

    serializer = serializerBuilder.build();
  }
  return serializer;
}
 
Example #23
Source File: DefaultDistributedCollectionService.java    From atomix with Apache License 2.0 5 votes vote down vote up
protected DefaultDistributedCollectionService(PrimitiveType primitiveType, T collection) {
  super(primitiveType, DistributedCollectionClient.class);
  this.collection = collection;
  this.serializer = Serializer.using(Namespace.builder()
      .register(primitiveType.namespace())
      .register(SessionId.class)
      .register(IteratorContext.class)
      .build());
}
 
Example #24
Source File: DistributedMultisetType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .register(Namespaces.BASIC)
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(CollectionUpdateResult.class)
      .register(CollectionUpdateResult.Status.class)
      .register(CollectionEvent.class)
      .register(CollectionEvent.Type.class)
      .register(IteratorBatch.class)
      .build();
}
 
Example #25
Source File: DefaultDistributedMultisetService.java    From atomix with Apache License 2.0 5 votes vote down vote up
public DefaultDistributedMultisetService() {
  super(DistributedMultisetType.instance(), HashMultiset.create());
  this.serializer = Serializer.using(Namespace.builder()
      .register(DistributedMultisetType.instance().namespace())
      .register(SessionId.class)
      .register(DefaultDistributedCollectionService.IteratorContext.class)
      .register(IteratorContext.class)
      .build());
}
 
Example #26
Source File: WorkQueueType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(Task.class)
      .register(WorkQueueStats.class)
      .build();
}
 
Example #27
Source File: MultimapBuilder.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
  if (serializer == null) {
    NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
    if (namespaceConfig == null) {
      namespaceConfig = new NamespaceConfig();
    }

    SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
    serializerBuilder.withNamespace(new Namespace(namespaceConfig));

    if (config.isRegistrationRequired()) {
      serializerBuilder.withRegistrationRequired();
    }
    if (config.isCompatibleSerialization()) {
      serializerBuilder.withCompatibleSerialization();
    }

    if (config.getKeyType() != null) {
      serializerBuilder.addType(config.getKeyType());
    }
    if (config.getValueType() != null) {
      serializerBuilder.addType(config.getValueType());
    }
    if (!config.getExtraTypes().isEmpty()) {
      serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
    }

    serializer = serializerBuilder.build();
  }
  return serializer;
}
 
Example #28
Source File: AtomicMultimapType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(Versioned.class)
      .register(ArrayList.class)
      .register(Maps.immutableEntry("", "").getClass())
      .register(IteratorBatch.class)
      .build();
}
 
Example #29
Source File: DistributedMultimapType.java    From atomix with Apache License 2.0 5 votes vote down vote up
@Override
public Namespace namespace() {
  return Namespace.builder()
      .register(PrimitiveType.super.namespace())
      .nextId(Namespaces.BEGIN_USER_CUSTOM_ID)
      .register(Versioned.class)
      .register(ArrayList.class)
      .register(Maps.immutableEntry("", "").getClass())
      .register(IteratorBatch.class)
      .build();
}
 
Example #30
Source File: AtomixClusterManager.java    From atomix-vertx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Vert.x compatible serializer.
 */
private Serializer createSerializer() {
  return Serializer.using(Namespace.builder()
      .setRegistrationRequired(false)
      .register(Namespaces.BASIC)
      .register(ServerID.class)
      .register(new ClusterSerializableSerializer<>(), ClusterSerializable.class)
      .build());
}