Skip to content

Commit 4382742

Browse files
committed
[#441] Schemas API
1 parent 656af4e commit 4382742

File tree

17 files changed

+724
-86
lines changed

17 files changed

+724
-86
lines changed

documentation/asciidoc/topics/ref_hotrod_java_tutorials.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
|link:{repository}/infinispan-remote/programmatic-protostream-marshalling[Custom marshalling]
3030
|Demonstrates how custom marshalling works in the context of programmatically creating Protostream schemas and marshallers. Users should generally rely on annotations based generated Protostream marshallers unless exceptional circumstances require manual creation.
3131

32+
|link:{repository}/infinispan-remote/schemas[Protostream schemas administration]
33+
|Demonstrates how to use the Administration API to manipulate the Protostream (protobuf format) schemas in {brandname}.
34+
3235
|link:{repository}/infinispan-remote/listeners[Client listeners]
3336
|Detect when data changes in a remote cache with Client Listeners.
3437

infinispan-embedded/query-programmatic-index/pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@
3333
</arguments>
3434
</configuration>
3535
</plugin>
36-
<plugin>
37-
<groupId>org.apache.maven.plugins</groupId>
38-
<artifactId>maven-compiler-plugin</artifactId>
39-
<configuration>
40-
<basedir/>
41-
<mainOutputDirectory/>
42-
<mojoStatusPath/>
43-
<outputDirectory/>
44-
<projectArtifact/>
45-
<source>21</source>
46-
<target>21</target>
47-
<compilerArgs>--enable-preview</compilerArgs>
48-
</configuration>
49-
</plugin>
5036
</plugins>
5137
</build>
5238

infinispan-remote/continuous-query/src/main/java/org/infinispan/tutorial/simple/remote/query/InfinispanRemoteContinuousQuery.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package org.infinispan.tutorial.simple.remote.query;
22

3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
import java.util.Random;
7+
import java.util.UUID;
8+
39
import org.infinispan.client.hotrod.RemoteCache;
410
import org.infinispan.client.hotrod.RemoteCacheManager;
511
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
@@ -8,14 +14,6 @@
814
import org.infinispan.commons.api.query.Query;
915
import org.infinispan.tutorial.simple.connect.TutorialsConnectorHelper;
1016

11-
import java.util.ArrayList;
12-
import java.util.Arrays;
13-
import java.util.List;
14-
import java.util.Random;
15-
import java.util.UUID;
16-
17-
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME;
18-
1917
/**
2018
* The Remote Continuous Query simple tutorial.
2119
*
@@ -145,11 +143,6 @@ public static void disconnect() {
145143
}
146144

147145
private static void register(InstaSchemaImpl schema, RemoteCacheManager cacheManager) {
148-
// Retrieve metadata cache
149-
RemoteCache<String, String> metadataCache =
150-
cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
151-
152-
// register the new schema on the server too
153-
metadataCache.putIfAbsent(schema.getProtoFileName(), schema.getProtoFile());
146+
cacheManager.administration().schemas().createOrUpdate(schema);
154147
}
155148
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
package org.infinispan.tutorial.simple.remote.persistence;
22

3-
import org.infinispan.client.hotrod.RemoteCache;
43
import org.infinispan.client.hotrod.RemoteCacheManager;
5-
import org.infinispan.protostream.GeneratedSchema;
6-
7-
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME;
84

95
public class ProtostreamSchemaUploader {
106

7+
public static final TechLibrarySchemaImpl TECH_LIBRARY_SCHEMA = new TechLibrarySchemaImpl();
118
private final RemoteCacheManager cacheManager;
129

1310
public ProtostreamSchemaUploader(RemoteCacheManager cacheManager) {
1411
this.cacheManager = cacheManager;
1512
}
1613

1714
public void registerSchema() {
18-
RemoteCache<String, String> metadataCache =
19-
cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
20-
GeneratedSchema schema = new TechLibrarySchemaImpl();
21-
metadataCache.put(schema.getProtoFileName(), schema.getProtoFile());
15+
cacheManager.administration().schemas().createOrUpdate(TECH_LIBRARY_SCHEMA);
2216
}
2317

2418
public void unregisterSchema() {
25-
RemoteCache<String, String> metadataCache =
26-
cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
27-
GeneratedSchema schema = new TechLibrarySchemaImpl();
28-
metadataCache.remove(schema.getProtoFileName());
19+
cacheManager.administration().schemas().remove(TECH_LIBRARY_SCHEMA.getProtoFileName());
2920
}
3021
}

infinispan-remote/programmatic-protostream-marshalling/src/main/java/org/infinispan/tutorial/simple/remote/marshalling/InfinispanProgrammaticProtostreamMarshalling.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.infinispan.tutorial.simple.remote.marshalling;
22

3-
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME;
43
import static org.infinispan.tutorial.simple.connect.TutorialsConnectorHelper.TUTORIAL_CACHE_NAME;
54

65
import java.time.YearMonth;
@@ -73,12 +72,7 @@ static void manipulateCache() {
7372
}
7473

7574
private static void registerMagazineSchemaInTheServer(RemoteCacheManager cacheManager) {
76-
// Retrieve metadata cache
77-
RemoteCache<String, String> metadataCache =
78-
cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
79-
80-
// Define the new schema on the server too
81-
metadataCache.put(schema.getName(), schema.toString());
75+
cacheManager.administration().schemas().createOrUpdate(schema);
8276
}
8377

8478
public static void disconnect(boolean removeCaches) {

infinispan-remote/query/src/main/java/org/infinispan/tutorial/simple/remote/query/InfinispanRemoteQuery.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
import org.infinispan.client.hotrod.RemoteCacheManager;
55
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
66
import org.infinispan.commons.api.query.Query;
7-
import org.infinispan.protostream.GeneratedSchema;
87
import org.infinispan.tutorial.simple.connect.TutorialsConnectorHelper;
98

109
import java.net.URI;
1110
import java.util.HashMap;
1211
import java.util.List;
1312
import java.util.Map;
1413

15-
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME;
16-
1714
/**
1815
* The Remote Query simple tutorial.
1916
*
@@ -148,12 +145,6 @@ public static void disconnect(boolean removeCaches) {
148145
record PersonDTO(String pseudo, String fullName){}
149146

150147
private static void addPersonSchema(RemoteCacheManager cacheManager) {
151-
// Retrieve metadata cache
152-
RemoteCache<String, String> metadataCache =
153-
cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
154-
155-
// Define the new schema on the server too
156-
GeneratedSchema schema = new TutorialSchemaImpl();
157-
metadataCache.put(schema.getProtoFileName(), schema.getProtoFile());
148+
cacheManager.administration().schemas().createOrUpdate(new TutorialSchemaImpl());
158149
}
159150
}
61.1 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

0 commit comments

Comments
 (0)