public static CoordinationService<InternalSchemaMetadata> createDefault( KeyValueService keyValueService, LongSupplier timestampSupplier, boolean initializeAsync) { CoordinationService<VersionedInternalSchemaMetadata> versionedService = new CoordinationServiceImpl<>( KeyValueServiceCoordinationStore.create( ObjectMappers.newServerObjectMapper(), keyValueService, AtlasDbConstants.DEFAULT_METADATA_COORDINATION_KEY, timestampSupplier, VersionedInternalSchemaMetadata.class, initializeAsync)); return wrapHidingVersionSerialization(versionedService); } }
public ShimJdk7Module() { super(ShimJdk7Module.class.getCanonicalName()); final JsonSerializer<Object> stringSer = ToStringSerializer.instance; addSerializer(Path.class, stringSer); addDeserializer(Path.class, new PathDeserializer()); }
/** * Returns result of {@link #newClientObjectMapper()}. This method maintains source and binary * compatibility with previous releases of the 2.x branch. * * @deprecated use {@link #newClientObjectMapper()} instead. */ @Deprecated public static ObjectMapper guavaJdk7Jdk8() { return newClientObjectMapper(); }
/** * Returns a default ObjectMapper with settings adjusted for use in servers. * <p> * Settings: * <ul> * <li>Throw on unknown properties found during deserialization. * </ul> */ public static ObjectMapper newServerObjectMapper() { return withDefaultModules(new ObjectMapper()) .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
/** * Configures provided ObjectMapper with default modules and settings. * <p> * Modules: Guava, JDK7, JDK8, Afterburner, JavaTime * <p> * Settings: * <ul> * <li>Dates written as ISO-8601 strings. * <li>Dates remain in received timezone. * <li>Exceptions will not be wrapped with Jackson exceptions. * <li>Deserializing a null for a primitive field will throw an exception. * </ul> */ public static ObjectMapper withDefaultModules(ObjectMapper mapper) { return mapper .registerModule(new GuavaModule()) .registerModule(new ShimJdk7Module()) .registerModule(new Jdk8Module().configureAbsentsAsNulls(true)) .registerModule(new AfterburnerModule()) .registerModule(new JavaTimeModule()) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(DeserializationFeature.WRAP_EXCEPTIONS) .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) .enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES); } }
context.register(new JacksonCBORProvider(ObjectMappers.newCborServerObjectMapper()));
@Test public void canDeserializeV1Metadata() throws URISyntaxException, IOException { String resourcePath = getResourcePath("internalschema-persistence/metadata-v1-1.json"); byte[] bytes = Files.readAllBytes(Paths.get(resourcePath)); VersionedInternalSchemaMetadata versionedInternalSchemaMetadata = ObjectMappers.newServerObjectMapper().readValue(bytes, VersionedInternalSchemaMetadata.class); assertThat(InternalSchemaMetadataPayloadCodec.decode(versionedInternalSchemaMetadata)) .isEqualTo(INTERNAL_SCHEMA_METADATA); }
/** * Returns a default ObjectMapper with settings adjusted for use in clients. * <p> * Settings: * <ul> * <li>Ignore unknown properties found during deserialization. * </ul> */ public static ObjectMapper newClientObjectMapper() { return withDefaultModules(new ObjectMapper()) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
@Test public void multipleStoresCanCoexist() { byte[] otherCoordinationKey = PtBytes.toBytes("bbbbb"); CoordinationStore<String> otherCoordinationStore = KeyValueServiceCoordinationStore.create( ObjectMappers.newServerObjectMapper(), keyValueService, otherCoordinationKey, timestampSequence::incrementAndGet, String.class, false); coordinationStore.transformAgreedValue(unused -> VALUE_1); otherCoordinationStore.transformAgreedValue(unused -> VALUE_2); assertThat(coordinationStore.getAgreedValue().get().value()).contains(VALUE_1); assertThat(otherCoordinationStore.getAgreedValue().get().value()).contains(VALUE_2); } }
/** * Returns a default ObjectMapper which uses the cbor factory with settings adjusted for use in servers. * <p> * Settings: * <ul> * <li>Throw on unknown properties found during deserialization. * </ul> */ public static ObjectMapper newCborServerObjectMapper() { return withDefaultModules(new ObjectMapper(new CBORFactory())) .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
private static TransactionSchemaManager createTransactionSchemaManager(TimestampService ts) { CoordinationServiceImpl<VersionedInternalSchemaMetadata> rawService = new CoordinationServiceImpl<>( KeyValueServiceCoordinationStore.create( ObjectMappers.newServerObjectMapper(), new InMemoryKeyValueService(true), PtBytes.toBytes("aaa"), ts::getFreshTimestamp, VersionedInternalSchemaMetadata.class, false)); return new TransactionSchemaManager(CoordinationServices.wrapHidingVersionSerialization(rawService)); }
/** * Returns a default ObjectMapper which uses the cbor factory with settings adjusted for use in clients. * <p> * Settings: * <ul> * <li>Ignore unknown properties found during deserialization. * </ul> */ public static ObjectMapper newCborClientObjectMapper() { return withDefaultModules(new ObjectMapper(new CBORFactory())) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
public static CoordinationService<InternalSchemaMetadata> createDefault( KeyValueService keyValueService, LongSupplier timestampSupplier, boolean initializeAsync) { CoordinationService<VersionedInternalSchemaMetadata> versionedService = new CoordinationServiceImpl<>( KeyValueServiceCoordinationStore.create( ObjectMappers.newServerObjectMapper(), keyValueService, AtlasDbConstants.DEFAULT_METADATA_COORDINATION_KEY, timestampSupplier, VersionedInternalSchemaMetadata.class, initializeAsync)); return wrapHidingVersionSerialization(versionedService); } }