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;
}
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");
}
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;
}
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();
}
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);
}
Aggregations