Exemplo n.º 1
0
 /**
  * Asynchronously write to the logging unit.
  *
  * @param address The address to write to.
  * @param streams The streams, if any, that this write belongs to.
  * @param rank The rank of this write (used for quorum replication).
  * @param writeObject The object, pre-serialization, to write.
  * @param backpointerMap The map of backpointers to write.
  * @return A CompletableFuture which will complete with the WriteResult once the write completes.
  */
 public CompletableFuture<Boolean> write(
     long address,
     Set<UUID> streams,
     long rank,
     Object writeObject,
     Map<UUID, Long> backpointerMap) {
   ByteBuf payload = ByteBufAllocator.DEFAULT.buffer();
   Serializers.getSerializer(CORFU).serialize(writeObject, payload);
   WriteRequest wr = new WriteRequest(WriteMode.NORMAL, null, payload);
   wr.setStreams(streams);
   wr.setRank(rank);
   wr.setBackpointerMap(backpointerMap);
   wr.setGlobalAddress(address);
   return router.sendMessageAndGetCompletable(CorfuMsgType.WRITE.payloadMsg(wr));
 }
  @Test
  @SuppressWarnings("unchecked")
  public void canUseCustomSerializer() throws Exception {
    // Register a custom serializer and use it with an SMR object
    Serializers.setCustomSerializer(SerializerType.JSON.getSerializer());
    CorfuRuntime r = getDefaultRuntime();

    Map<String, String> test =
        r.getObjectsView()
            .build()
            .setType(SMRMap.class)
            .setStreamName("test")
            .setSerializer(SerializerType.CUSTOM)
            .open();

    test.put("a", "b");
    test.get("a");
    assertThat(test.get("a")).isEqualTo("b");
  }
Exemplo n.º 3
0
 public CompletableFuture<Boolean> writeStream(
     long address, Map<UUID, Long> streamAddresses, Object object) {
   ByteBuf payload = ByteBufAllocator.DEFAULT.buffer();
   Serializers.getSerializer(CORFU).serialize(object, payload);
   return writeStream(address, streamAddresses, payload);
 }