本文整理了Java中com.esotericsoftware.kryo.Registration.getId
方法的一些代码示例,展示了Registration.getId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registration.getId
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Registration
类名称:Registration
方法名:getId
[英]Returns the registered class ID.
[中]返回注册的类ID。
代码示例来源:origin: EsotericSoftware/kryonet
cachedMethod.methodClassID = kryo.getRegistration(method.getDeclaringClass()).getId();
cachedMethod.methodIndex = i;
代码示例来源:origin: atomix/atomix
if (r.getId() != id) {
LOGGER.debug("{}: {} already registered as {}. Skipping {}.",
friendlyName(), r.getType(), r.getId(), id);
LOGGER.trace("{} registered as {}", r.getType(), r.getId());
代码示例来源:origin: apache/flink
for (int i = 0; i < nextId; i++) {
Registration registration = kryo.getRegistration(i);
String str = registration.getId() + "," + registration.getType().getName();
writer.write(str, 0, str.length());
writer.newLine();
代码示例来源:origin: apache/flink
@Test
public void testTypeRegistrationFromTypeInfo() {
ExecutionConfig conf = new ExecutionConfig();
Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>());
KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
// check if the generic type from one field is also registered (its very likely that
// generic types are also used as fields somewhere.
assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
}
}
代码示例来源:origin: apache/flink
@Test
public void testTypeRegistration() {
ExecutionConfig conf = new ExecutionConfig();
Serializers.recursivelyRegisterType(ClassWithNested.class, conf, new HashSet<Class<?>>());
KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
Assert.assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
Assert.assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
Assert.assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
// check if the generic type from one field is also registered (its very likely that
// generic types are also used as fields somewhere.
Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
Assert.assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
// register again and make sure classes are still registered
ExecutionConfig conf2 = new ExecutionConfig();
Serializers.recursivelyRegisterType(ClassWithNested.class, conf2, new HashSet<Class<?>>());
KryoSerializer<String> kryo2 = new KryoSerializer<>(String.class, conf);
assertTrue(kryo2.getKryo().getRegistration(FromNested.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testFoldingStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
@SuppressWarnings("unchecked")
FoldFunction<String, TaskInfo> folder = (FoldFunction<String, TaskInfo>) mock(FoldFunction.class);
FoldingStateDescriptor<String, TaskInfo> descr =
new FoldingStateDescriptor<>("name", null, folder, TaskInfo.class);
context.getFoldingState(descr);
FoldingStateDescriptor<?, ?> descrIntercepted = (FoldingStateDescriptor<?, ?>) descriptorCapture.get();
TypeSerializer<?> serializer = descrIntercepted.getSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(serializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testReducingStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
@SuppressWarnings("unchecked")
ReduceFunction<TaskInfo> reducer = (ReduceFunction<TaskInfo>) mock(ReduceFunction.class);
ReducingStateDescriptor<TaskInfo> descr =
new ReducingStateDescriptor<>("name", reducer, TaskInfo.class);
context.getReducingState(descr);
StateDescriptor<?, ?> descrIntercepted = (StateDescriptor<?, ?>) descriptorCapture.get();
TypeSerializer<?> serializer = descrIntercepted.getSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(serializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testAggregatingStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
@SuppressWarnings("unchecked")
AggregateFunction<String, TaskInfo, String> aggregate = (AggregateFunction<String, TaskInfo, String>) mock(AggregateFunction.class);
AggregatingStateDescriptor<String, TaskInfo, String> descr =
new AggregatingStateDescriptor<>("name", aggregate, TaskInfo.class);
context.getAggregatingState(descr);
AggregatingStateDescriptor<?, ?, ?> descrIntercepted = (AggregatingStateDescriptor<?, ?, ?>) descriptorCapture.get();
TypeSerializer<?> serializer = descrIntercepted.getSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(serializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testValueStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
ValueStateDescriptor<TaskInfo> descr = new ValueStateDescriptor<>("name", TaskInfo.class);
context.getState(descr);
StateDescriptor<?, ?> descrIntercepted = (StateDescriptor<?, ?>) descriptorCapture.get();
TypeSerializer<?> serializer = descrIntercepted.getSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(serializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) serializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testMapStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
MapStateDescriptor<String, TaskInfo> descr =
new MapStateDescriptor<>("name", String.class, TaskInfo.class);
context.getMapState(descr);
MapStateDescriptor<?, ?> descrIntercepted = (MapStateDescriptor<?, ?>) descriptorCapture.get();
TypeSerializer<?> valueSerializer = descrIntercepted.getValueSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(valueSerializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) valueSerializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
int testClassId = kryoSerializer.getKryo().getRegistration(TestClass.class).getId();
int testClassAId = kryoSerializer.getKryo().getRegistration(TestClassA.class).getId();
int testClassBId = kryoSerializer.getKryo().getRegistration(TestClassB.class).getId();
kryoSerializerConfigSnapshot.resolveSchemaCompatibility(kryoSerializer);
assertTrue(compatResult.isCompatibleAsIs());
assertEquals(testClassId, kryoSerializer.getKryo().getRegistration(TestClass.class).getId());
assertEquals(testClassAId, kryoSerializer.getKryo().getRegistration(TestClassA.class).getId());
assertEquals(testClassBId, kryoSerializer.getKryo().getRegistration(TestClassB.class).getId());
代码示例来源:origin: apache/flink
@Test
public void testListStateInstantiation() throws Exception {
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(Path.class);
final AtomicReference<Object> descriptorCapture = new AtomicReference<>();
StreamingRuntimeContext context = new StreamingRuntimeContext(
createDescriptorCapturingMockOp(descriptorCapture, config),
createMockEnvironment(),
Collections.<String, Accumulator<?, ?>>emptyMap());
ListStateDescriptor<TaskInfo> descr = new ListStateDescriptor<>("name", TaskInfo.class);
context.getListState(descr);
ListStateDescriptor<?> descrIntercepted = (ListStateDescriptor<?>) descriptorCapture.get();
TypeSerializer<?> serializer = descrIntercepted.getSerializer();
// check that the Path class is really registered, i.e., the execution config was applied
assertTrue(serializer instanceof ListSerializer);
TypeSerializer<?> elementSerializer = descrIntercepted.getElementSerializer();
assertTrue(elementSerializer instanceof KryoSerializer);
assertTrue(((KryoSerializer<?>) elementSerializer).getKryo().getRegistration(Path.class).getId() > 0);
}
代码示例来源:origin: apache/flink
@Test
public void testInitializeSerializerAfterSerializationWithCustomConfig() throws Exception {
// guard our test assumptions.
assertEquals("broken test assumption", -1,
new KryoSerializer<>(String.class, new ExecutionConfig()).getKryo()
.getRegistration(File.class).getId());
final ExecutionConfig config = new ExecutionConfig();
config.registerKryoType(File.class);
final TestStateDescriptor<Path> original = new TestStateDescriptor<>("test", Path.class);
TestStateDescriptor<Path> clone = CommonTestUtils.createCopySerializable(original);
clone.initializeSerializerUnlessSet(config);
// serialized one (later initialized) carries the registration
assertTrue(((KryoSerializer<?>) clone.getSerializer()).getKryo()
.getRegistration(File.class).getId() > 0);
}
代码示例来源:origin: spring-projects/spring-integration
private void register(Kryo kryo, Registration registration) {
int id = registration.getId();
Registration existing = kryo.getRegistration(id);
if (existing != null) {
throw new IllegalStateException("registration already exists " + existing);
}
if (this.log.isInfoEnabled()) {
this.log.info(String.format("registering %s with serializer %s", registration,
registration.getSerializer().getClass().getName()));
}
kryo.register(registration);
}
代码示例来源:origin: spring-projects/spring-integration
private void validateRegistrations() {
List<Integer> ids = new ArrayList<Integer>();
List<Class<?>> types = new ArrayList<Class<?>>();
for (Registration registration : getRegistrations()) {
Assert.isTrue(registration.getId() >= MIN_REGISTRATION_VALUE,
"registration ID must be >= " + MIN_REGISTRATION_VALUE);
if (ids.contains(registration.getId())) {
throw new RuntimeException(String.format("Duplicate registration ID found: %d",
registration.getId()));
}
ids.add(registration.getId());
if (types.contains(registration.getType())) {
throw new RuntimeException(String.format("Duplicate registration found for type: %s",
registration.getType()));
}
types.add(registration.getType());
if (log.isInfoEnabled()) {
log.info(String.format("configured Kryo registration %s with serializer %s", registration,
registration.getSerializer().getClass().getName()));
}
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-memcached-core
@Override
public Registration register(final Registration registration) {
LOGGER.debug("Registering class [{}] with Kryo using id [{}]", registration.getType().getName(), registration.getId());
return super.register(registration);
}
}
代码示例来源:origin: org.springframework.xd/spring-xd-codec
protected void register(Kryo kryo, Registration registration) {
int id = registration.getId();
Registration existing = kryo.getRegistration(id);
if (existing != null) {
throw new SerializationException(String.format("registration already exists %s", existing));
}
log.info("registering {} with serializer {}", registration, registration.getSerializer().getClass()
.getName());
kryo.register(registration);
}
}
代码示例来源:origin: com.tinkerpop/gremlin-core
@Override
public Registration register(final Registration registration) {
if (null == registration) throw new IllegalArgumentException("Registration cannot be null.");
if (registration.getId() != NAME) idToRegistration.put(registration.getId(), registration);
classToRegistration.put(registration.getType(), registration);
if (registration.getType().isPrimitive())
classToRegistration.put(getWrapperClass(registration.getType()), registration);
return registration;
}
代码示例来源:origin: co.paralleluniverse/quasar-core
private void register(Registration r) {
if (r.getId() < 0 && r.getSerializer() == NULL_SERIALIZER)
kryo.register(r.getType());
else if (r.getId() < 0)
kryo.register(r.getType(), r.getSerializer());
else if (r.getSerializer() == NULL_SERIALIZER)
kryo.register(r.getType(), r.getId());
else
kryo.register(r.getType(), r.getSerializer(), r.getId());
}
代码示例来源:origin: co.paralleluniverse/galaxy
private void register(Registration r) {
if (r.getId() < 0 && r.getSerializer() == NULL_SERIALIZER)
kryo.register(r.getType());
else if (r.getId() < 0)
kryo.register(r.getType(), r.getSerializer());
else if (r.getSerializer() == NULL_SERIALIZER)
kryo.register(r.getType(), r.getId());
else
kryo.register(r.getType(), r.getSerializer(), r.getId());
}
内容来源于网络,如有侵权,请联系作者删除!