Search in sources :

Example 1 with NamedType

use of com.fasterxml.jackson.databind.jsontype.NamedType in project druid by druid-io.

the class TaskLifecycleTest method setUpTaskStorage.

private TaskStorage setUpTaskStorage() {
    Preconditions.checkNotNull(mapper);
    Preconditions.checkNotNull(derbyConnectorRule);
    TaskStorage taskStorage;
    switch(taskStorageType) {
        case HEAP_TASK_STORAGE:
            {
                taskStorage = new HeapMemoryTaskStorage(new TaskStorageConfig(null) {
                });
                break;
            }
        case METADATA_TASK_STORAGE:
            {
                TestDerbyConnector testDerbyConnector = derbyConnectorRule.getConnector();
                mapper.registerSubtypes(new NamedType(MockExceptionalFirehoseFactory.class, "mockExcepFirehoseFactory"), new NamedType(MockFirehoseFactory.class, "mockFirehoseFactory"));
                testDerbyConnector.createTaskTables();
                testDerbyConnector.createSegmentTable();
                taskStorage = new MetadataTaskStorage(testDerbyConnector, new TaskStorageConfig(null), new SQLMetadataStorageActionHandlerFactory(testDerbyConnector, derbyConnectorRule.metadataTablesConfigSupplier().get(), mapper));
                break;
            }
        default:
            {
                throw new RuntimeException(String.format("Unknown task storage type [%s]", taskStorageType));
            }
    }
    tsqa = new TaskStorageQueryAdapter(taskStorage);
    return taskStorage;
}
Also used : TaskStorageConfig(io.druid.indexing.common.config.TaskStorageConfig) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) SQLMetadataStorageActionHandlerFactory(io.druid.metadata.SQLMetadataStorageActionHandlerFactory) TestDerbyConnector(io.druid.metadata.TestDerbyConnector)

Example 2 with NamedType

use of com.fasterxml.jackson.databind.jsontype.NamedType in project druid by druid-io.

the class WorkerTaskMonitorTest method setUp.

@Before
public void setUp() throws Exception {
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(false)).build();
    cf.start();
    cf.blockUntilConnected();
    cf.create().creatingParentsIfNeeded().forPath(basePath);
    worker = new Worker("worker", "localhost", 3, "0");
    workerCuratorCoordinator = new WorkerCuratorCoordinator(jsonMapper, new IndexerZkConfig(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return basePath;
        }
    }, null, null, null, null, null), new TestRemoteTaskRunnerConfig(new Period("PT1S")), cf, worker);
    workerCuratorCoordinator.start();
    // Start a task monitor
    workerTaskMonitor = createTaskMonitor();
    TestTasks.registerSubtypes(jsonMapper);
    jsonMapper.registerSubtypes(new NamedType(TestRealtimeTask.class, "test_realtime"));
    workerTaskMonitor.start();
    task = TestTasks.immediateSuccess("test");
}
Also used : IndexerZkConfig(io.druid.server.initialization.IndexerZkConfig) TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) Period(org.joda.time.Period) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) TestRealtimeTask(io.druid.indexing.common.TestRealtimeTask) TestingCluster(org.apache.curator.test.TestingCluster) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) Before(org.junit.Before)

Example 3 with NamedType

use of com.fasterxml.jackson.databind.jsontype.NamedType in project airpal by airbnb.

the class DropwizardModule method provideObjectMapper.

@Singleton
@Provides
protected ObjectMapper provideObjectMapper() {
    ObjectMapper mapper = environment.getObjectMapper();
    mapper.registerSubtypes(new NamedType(CSVPersistentOutput.class, "csv"), new NamedType(HiveTablePersistentOutput.class, "hive"));
    Rosetta.getMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Rosetta.getMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
    return mapper;
}
Also used : HiveTablePersistentOutput(com.airbnb.airpal.api.output.HiveTablePersistentOutput) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) CSVPersistentOutput(com.airbnb.airpal.api.output.CSVPersistentOutput) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 4 with NamedType

use of com.fasterxml.jackson.databind.jsontype.NamedType in project swagger-core by swagger-api.

the class SwaggerAnnotationIntrospector method findSubtypes.

@Override
public List<NamedType> findSubtypes(Annotated a) {
    final ApiModel api = a.getAnnotation(ApiModel.class);
    if (api != null) {
        final Class<?>[] classes = api.subTypes();
        final List<NamedType> names = new ArrayList<NamedType>(classes.length);
        for (Class<?> subType : classes) {
            names.add(new NamedType(subType));
        }
        if (!names.isEmpty()) {
            return names;
        }
    }
    return Collections.emptyList();
}
Also used : NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) ArrayList(java.util.ArrayList) AnnotatedClass(com.fasterxml.jackson.databind.introspect.AnnotatedClass) ApiModel(io.swagger.annotations.ApiModel)

Example 5 with NamedType

use of com.fasterxml.jackson.databind.jsontype.NamedType in project jackson-databind by FasterXML.

the class StdSubtypeResolver method collectAndResolveSubtypesByTypeId.

/*
    /**********************************************************
    /* Resolution by class (deserialization)
    /**********************************************************
     */
@Override
public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) {
    final AnnotationIntrospector ai = config.getAnnotationIntrospector();
    Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass();
    // Need to keep track of classes that have been handled already 
    Set<Class<?>> typesHandled = new HashSet<Class<?>>();
    Map<String, NamedType> byName = new LinkedHashMap<String, NamedType>();
    // start with lowest-precedence, which is from type hierarchy
    NamedType rootType = new NamedType(rawBase, null);
    AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(rawBase, config);
    _collectAndResolveByTypeId(ac, rootType, config, typesHandled, byName);
    // then with definitions from property
    Collection<NamedType> st = ai.findSubtypes(property);
    if (st != null) {
        for (NamedType nt : st) {
            ac = AnnotatedClass.constructWithoutSuperTypes(nt.getType(), config);
            _collectAndResolveByTypeId(ac, nt, config, typesHandled, byName);
        }
    }
    // and finally explicit type registrations (highest precedence)
    if (_registeredSubtypes != null) {
        for (NamedType subtype : _registeredSubtypes) {
            // is it a subtype of root type?
            if (rawBase.isAssignableFrom(subtype.getType())) {
                // yes
                AnnotatedClass curr = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config);
                _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName);
            }
        }
    }
    return _combineNamedAndUnnamed(typesHandled, byName);
}
Also used : NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector)

Aggregations

NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)27 AnnotationIntrospector (com.fasterxml.jackson.databind.AnnotationIntrospector)4 JavaType (com.fasterxml.jackson.databind.JavaType)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ApiModel (io.swagger.annotations.ApiModel)3 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)2 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)2 TypeSerializer (com.fasterxml.jackson.databind.jsontype.TypeSerializer)2 DataSchema (io.druid.segment.indexing.DataSchema)2 UniformGranularitySpec (io.druid.segment.indexing.granularity.UniformGranularitySpec)2 HashBasedNumberedShardSpec (io.druid.timeline.partition.HashBasedNumberedShardSpec)2 ApiModelProperty (io.swagger.annotations.ApiModelProperty)2 ComposedModel (io.swagger.models.ComposedModel)2 Model (io.swagger.models.Model)2 ModelImpl (io.swagger.models.ModelImpl)2 RefModel (io.swagger.models.RefModel)2 AbstractNumericProperty (io.swagger.models.properties.AbstractNumericProperty)2 ArrayProperty (io.swagger.models.properties.ArrayProperty)2