@Override
  protected void createCacheManagers() throws Throwable {
    // todo [anistor] initializing the server-side context in this way is a hack. normally this
    // should use the protobuf metadata registry
    MarshallerRegistration.registerMarshallers(
        SerializationContextHolder.getSerializationContext());

    // initialize client-side serialization context
    MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext());

    ConfigurationBuilder builder =
        hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false));
    builder
        .transaction()
        .indexing()
        .enable()
        .indexLocalOnly(false)
        .addProperty(
            "default.directory_provider", "ram") // todo test with  "infinispan" provider too
        .addProperty("lucene_version", "LUCENE_CURRENT");

    builder.dataContainer().valueEquivalence(AnyEquivalence.getInstance()); // TODO [anistor] hacks!

    createHotRodServers(2, builder);
  }
  @Override
  protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder cfgBuilder =
        hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
    createHotRodServers(NUM_NODES, cfgBuilder);
    waitForClusterToForm();

    for (int i = 0; i < NUM_NODES; i++) {
      server(i)
          .addCacheEventFilterFactory("custom-filter-factory", new CustomCacheEventFilterFactory());

      // WARNING! This is not the actual instance used at runtime. A new instance is created
      // instead, so all state is lost unless it is re-created in the constructor!
      ProtoStreamMarshaller marshaller = new CustomProtoStreamMarshaller();

      server(i).setMarshaller(marshaller);
    }

    // initialize server-side serialization context
    RemoteCache<String, String> metadataCache =
        client(0).getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
    metadataCache.put(
        "sample_bank_account/bank.proto",
        Util.read(
            Util.getResourceAsStream(
                "/sample_bank_account/bank.proto", getClass().getClassLoader())));
    assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));

    // initialize client-side serialization context
    MarshallerRegistration.registerMarshallers(
        ProtoStreamMarshaller.getSerializationContext(client(0)));

    remoteCache = client(0).getCache();
  }
  @Override
  protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder cfgBuilder =
        hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
    cfgBuilder
        .indexing()
        .index(Index.ALL)
        .addProperty("default.directory_provider", "ram")
        .addProperty("lucene_version", "LUCENE_CURRENT");

    createHotRodServers(NUM_NODES, cfgBuilder);

    waitForClusterToForm();

    remoteCache = client(0).getCache();

    // initialize server-side serialization context
    RemoteCache<String, String> metadataCache =
        client(0).getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
    metadataCache.put(
        "sample_bank_account/bank.proto",
        Util.read(
            Util.getResourceAsStream(
                "/sample_bank_account/bank.proto", getClass().getClassLoader())));
    assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));

    // initialize client-side serialization context
    MarshallerRegistration.registerMarshallers(
        ProtoStreamMarshaller.getSerializationContext(client(0)));
  }
  @BeforeClass
  protected void registerProtobufSchema() throws Exception {
    // initialize client-side serialization context
    String authorSchemaFile =
        "/* @Indexed */\n"
            + "message Author {\n"
            + "   required int32 id = 1;\n"
            + "   /* @IndexedField */\n"
            + "   required string name = 2;\n"
            + "}";
    SerializationContext serializationContext =
        ProtoStreamMarshaller.getSerializationContext(remoteCacheManager);
    serializationContext.registerProtoFiles(
        FileDescriptorSource.fromString("author.proto", authorSchemaFile));
    serializationContext.registerMarshaller(
        new MessageMarshaller<Author>() {
          @Override
          public Author readFrom(ProtoStreamReader reader) throws IOException {
            int id = reader.readInt("id");
            String name = reader.readString("name");
            Author author = new Author();
            author.setId(id);
            author.setName(name);
            return author;
          }

          @Override
          public void writeTo(ProtoStreamWriter writer, Author author) throws IOException {
            writer.writeInt("id", author.getId());
            writer.writeString("name", author.getName());
          }

          @Override
          public Class<? extends Author> getJavaClass() {
            return Author.class;
          }

          @Override
          public String getTypeName() {
            return "Author";
          }
        });

    ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
    String memoSchemaFile =
        protoSchemaBuilder.fileName("memo.proto").addClass(Memo.class).build(serializationContext);

    // initialize server-side serialization context
    RemoteCache<String, String> metadataCache =
        remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
    metadataCache.put("author.proto", authorSchemaFile);
    metadataCache.put("memo.proto", memoSchemaFile);
    assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
  }
  public RemoteQueryFactory(RemoteCacheImpl cache) {
    serializationContext =
        ProtoStreamMarshaller.getSerializationContext(cache.getRemoteCacheManager());

    this.cache = cache;

    try {
      MarshallerRegistration.registerMarshallers(serializationContext);
    } catch (Exception e) {
      throw new HotRodClientException("Failed to initialise the Protobuf serialization context", e);
    }
  }