use of org.infinispan.tools.store.migrator.marshaller.infinispan8.Infinispan8Marshaller in project infinispan by infinispan.
the class MigratorConfigurationTest method testInfinipsan8MarshallerAndExternalizersLoaded.
public void testInfinipsan8MarshallerAndExternalizersLoaded() throws Exception {
String externalizers = String.format("%d:%s", 1, PersonExternalizer.class.getName());
Properties properties = createBaseProperties();
properties.put(propKey(SOURCE, VERSION), String.valueOf(8));
properties.put(propKey(SOURCE, MARSHALLER, EXTERNALIZERS), externalizers);
StoreProperties props = new StoreProperties(SOURCE, properties);
Marshaller marshaller = SerializationConfigUtil.getMarshaller(props);
assertNotNull(marshaller);
assertTrue(marshaller instanceof Infinispan8Marshaller);
byte[] bytes = new byte[] { 3, 1, -2, 3, -1, 1, 1 };
Object object = marshaller.objectFromByteBuffer(bytes);
assertNotNull(object);
assertTrue(object instanceof Person);
assertEquals(1, externalizerReadCount.get());
}
use of org.infinispan.tools.store.migrator.marshaller.infinispan8.Infinispan8Marshaller in project infinispan by infinispan.
the class SerializationConfigUtil method getMarshaller.
public static Marshaller getMarshaller(StoreProperties props) {
int majorVersion = props.getMajorVersion();
if (props.isTargetStore() && majorVersion != Integer.parseInt(Version.getMajor())) {
throw new CacheConfigurationException(String.format("The marshaller associated with Infinispan %d can only be specified for source stores.", majorVersion));
}
if (majorVersion < 8 || majorVersion > Integer.parseInt(Version.getMajor())) {
throw new IllegalStateException(String.format("Unexpected major version '%d'", majorVersion));
}
switch(majorVersion) {
case 8:
case 9:
Marshaller marshaller = loadMarshallerInstance(props);
if (marshaller != null) {
return marshaller;
}
Map<Integer, AdvancedExternalizer> userExts = getExternalizersFromProps(props);
return majorVersion == 8 ? new Infinispan8Marshaller(userExts) : new Infinispan9Marshaller(userExts);
case 10:
case 11:
String marshallerClass = props.get(MARSHALLER, CLASS);
PersistenceMarshaller pm = createPersistenceMarshaller(props);
if (marshallerClass != null) {
// If a custom marshaller was specified, then return PersistenceMarshaller as user values are all wrapped
return pm;
}
// Return the user marshaller so that PersistenceMarshaller object wrapping is avoided
return pm.getUserMarshaller();
default:
return props.isTargetStore() ? null : createPersistenceMarshaller(props);
}
}
use of org.infinispan.tools.store.migrator.marshaller.infinispan8.Infinispan8Marshaller in project infinispan by infinispan.
the class LegacyMarshallerTest method beforeTest.
@BeforeClass(alwaysRun = true)
public void beforeTest() throws Exception {
Map<Integer, AdvancedExternalizer> userExts = new HashMap<>();
userExts.put(256, new TestUtil.TestObjectExternalizer());
this.marshaller = majorVersion == 8 ? new Infinispan8Marshaller(userExts) : new Infinispan9Marshaller(userExts);
String filename = String.format("src/test/resources/infinispan%d/marshalled_bytes.bin", majorVersion);
Path path = new File(filename).toPath();
byte[] bytes = Files.readAllBytes(path);
byteMap = (Map<String, byte[]>) marshaller.objectFromByteBuffer(bytes);
}
Aggregations