.fileName(fileName) .packageName(packageName);
private void addProtobufClass(SerializationContext serializationContext, String protoName, Class<?> clazz) { try { ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); protoSchemaBuilder.fileName(protoName); protoSchemaBuilder.addClass(clazz); String schemaString = protoSchemaBuilder.build(serializationContext); this.getProtobufCache().put(protoName, schemaString); } catch (IOException e) { throw new InfinispanException("Can't add protobuf class <" + protoName + "> to cache", e); } }
private void addProtobufClass(SerializationContext serializationContext, String protoName, Class<?> clazz) { try { ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); protoSchemaBuilder.fileName(protoName); protoSchemaBuilder.addClass(clazz); String schemaString = protoSchemaBuilder.build(serializationContext); this.getProtobufCache().put(protoName, schemaString); } catch (IOException e) { throw new InfinispanException("Can't add protobuf class <" + protoName + "> to cache", e); } }
@Override protected RemoteCacheManager createRemoteCacheManager() throws IOException { RemoteCacheManager remoteCacheManager = new RemoteCacheManager(new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServer().host("localhost").port(hotRodServer.getPort()) .marshaller(new ProtoStreamMarshaller()) .build()); //initialize client-side serialization context SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager); ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String protoFile = protoSchemaBuilder.fileName("crypto.proto") .addClass(CryptoCurrency.class) .build(serializationContext); //initialize server-side serialization context via rest endpoint String metadataCacheEndpoint = String.format("http://localhost:%s/rest/%s", restServer.getPort(), PROTOBUF_METADATA_CACHE_NAME); EntityEnclosingMethod put = new PutMethod(metadataCacheEndpoint + "/crypto.proto"); put.setRequestEntity(new StringRequestEntity(protoFile, "text/plain", "UTF-8")); restClient.executeMethod(put); assertEquals(put.getStatusCode(), HttpStatus.SC_OK); return remoteCacheManager; }
@Before public void before() throws IOException { ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder.addServer() .host(server.getHotrodEndpoint().getInetAddress().getHostName()) .port(server.getHotrodEndpoint().getPort()) .marshaller(new ProtoStreamMarshaller()); remoteCacheManager = new RemoteCacheManager(clientBuilder.build()); SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager); ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String protoSchema = protoSchemaBuilder.fileName("transaction.proto") .addClass(Transaction.class) .build(serializationContext); RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); metadataCache.put("transaction.proto", protoSchema); }
String testSchemaFile = protoSchemaBuilder.fileName("test.proto") .addClass(Note.class) .build(ctx);
@Before public void setUp() throws Exception { rcmFactory = new RemoteCacheManagerFactory(); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder.addServer() .host(server.getHotrodEndpoint().getInetAddress().getHostName()) .port(server.getHotrodEndpoint().getPort()) .marshaller(new ProtoStreamMarshaller()); remoteCacheManager = rcmFactory.createManager(clientBuilder); remoteCache = remoteCacheManager.getCache(cacheName); //initialize client-side serialization context SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager); ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String protoFile = protoSchemaBuilder.fileName("test.proto") .addClass(AnnotatedUser.class) .build(serializationContext); //initialize server-side serialization context RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); metadataCache.put("test.proto", protoFile); assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX)); }
@Override protected RemoteCacheManager createRemoteCacheManager() throws IOException { RemoteCacheManager remoteCacheManager = new RemoteCacheManager(new org.infinispan.client.hotrod.configuration.ConfigurationBuilder() .addServer().host("localhost").port(hotRodServer.getPort()) .marshaller(new ProtoStreamMarshaller()) .build()); //initialize client-side serialization context SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager); ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String protoFile = protoSchemaBuilder.fileName("crypto.proto") .addClass(CryptoCurrency.class) .build(serializationContext); //initialize server-side serialization context RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME); metadataCache.put("crypto.proto", protoFile); return remoteCacheManager; }