public ProtocolHandler<Protocol, Format> findHandlerFor( Protocol protocol ) { for( ProtocolHandler<Protocol, Format> handler : handlers ) { if( handler.handles( protocol ) ) return handler; } return null; }
public FormatHandler<Protocol, Format> findHandlerFor( Protocol protocol, Format format ) { for( FormatHandler<Protocol, Format> handler : handlers ) { if( handler.handles( protocol, format ) ) return handler; } return null; }
public ProtocolHandlers<Protocol, Format> getProtocolHandlers( Object context ) { if( !this.protocolHandlers.containsKey( context ) ) this.protocolHandlers.put( context, new ProtocolHandlers<Protocol, Format>() ); return this.protocolHandlers.get( context ); }
private Tap createTapFor( SchemaDef schemaDef, Stereotype<Protocol, Format> stereotype, Resource<Protocol, Format, SinkMode> resource ) { ProtocolHandler<Protocol, Format> protocolHandler = getProtocolHandlers( schemaDef ).findHandlerFor( resource.getProtocol() ); FormatHandler<Protocol, Format> formatHandler = getFormatHandlersFor( schemaDef ).findHandlerFor( resource.getProtocol(), resource.getFormat() ); if( protocolHandler == null || formatHandler == null ) return null; // do not make loadable, tap loadable will handle dynamic classloader issues Scheme scheme = formatHandler.createScheme( stereotype, resource.getProtocol(), resource.getFormat() ); return ( (LingualProtocolHandler) protocolHandler ).createLoadableTap( scheme, resource ); }
throw new IllegalStateException( "could not find handler for format: " + format ); scheme = formatHandler.createScheme( getProperties(), stereotype, protocol, format, role ); throw new IllegalStateException( "could not find handler for protocol: " + protocol ); taps[ i ] = protocolHandler.createTap( getProperties(), scheme, resource, role );
public FormatHandlers<Protocol, Format> getFormatHandlers( Object context ) { if( !this.formatHandlers.containsKey( context ) ) this.formatHandlers.put( context, new FormatHandlers<Protocol, Format>() ); return this.formatHandlers.get( context ); }
public void addHandlerProvider( HandlerProvider<Protocol, Format> handlerProvider ) { addProtocolHandlers( handlerProvider.getProtocolHandlers() ); addFormatHandlers( handlerProvider.getFormatHandlers() ); }
FormatHandler getFormatHandler( Object context, Protocol protocol, Format format ) { return getFormatHandlers( context ).findHandlerFor( protocol, format ); }
ProtocolHandler getProtocolHandler( Object context, Protocol protocol ) { return getProtocolHandlers( context ).findHandlerFor( protocol ); }
public Map<String, List<String>> getProtocolProperties( Protocol protocol ) { for( ProtocolHandler<Protocol, Format> handler : handlers ) { Map<String, List<String>> defaultProperties = handler.getDefaultProperties( protocol ); if( defaultProperties != null && !defaultProperties.isEmpty() ) return defaultProperties; } return Collections.emptyMap(); }
public Map<String, List<String>> getFormatProperties( Format format ) { for( FormatHandler<Protocol, Format> handler : handlers ) { Map<String, List<String>> defaultProperties = handler.getDefaultProperties( format ); if( defaultProperties != null && !defaultProperties.isEmpty() ) return defaultProperties; } return Collections.emptyMap(); }
public void addFormatHandlers( Object context, List<FormatHandler<Protocol, Format>> formatHandlers ) { getFormatHandlers( context ).addAll( formatHandlers ); }
public void addProtocolHandlers( Object context, List<ProtocolHandler<Protocol, Format>> protocolHandlers ) { getProtocolHandlers( context ).addAll( protocolHandlers ); }
public Set<Format> getFormats() { Set<Format> formats = new HashSet<Format>(); for( FormatHandler<Protocol, Format> handler : handlers ) { Collection<? extends Format> currentFormats = handler.getFormats(); if( !Collections.disjoint( formats, currentFormats ) ) LOG.warn( "format handler: {} provides one or more duplicate default formats: {}", handler, currentFormats ); else formats.addAll( currentFormats ); } return formats; }
public Set<Protocol> getProtocols() { Set<Protocol> protocols = new HashSet<Protocol>(); for( ProtocolHandler<Protocol, Format> handler : handlers ) { Collection<? extends Protocol> currentProtocols = handler.getProtocols(); if( !Collections.disjoint( protocols, currentProtocols ) ) LOG.warn( "protocol handler: {} provides one or more duplicate default protocols: {}", handler, currentProtocols ); else protocols.addAll( currentProtocols ); } return protocols; }
public Tap createTapFor( TableDef tableDef, SinkMode sinkMode ) { Protocol protocol = tableDef.getActualProtocol(); Format format = tableDef.getActualFormat(); ProtocolHandler<Protocol, Format> protocolHandler = getProtocolHandlers( tableDef.getParentSchema() ).findHandlerFor( protocol ); FormatHandler<Protocol, Format> formatHandler = getFormatHandlersFor( tableDef.getParentSchema() ).findHandlerFor( protocol, format ); if( protocolHandler == null ) throw new IllegalArgumentException( "no protocol handler for protocol: " + protocol ); if( formatHandler == null ) throw new IllegalArgumentException( "no format handler for format: " + format ); // do not make loadable, tap loadable will handle dynamic classloader issues Scheme scheme = formatHandler.createScheme( tableDef.getStereotype(), protocol, format ); Resource<Protocol, Format, SinkMode> resource = tableDef.getResourceWith( sinkMode ); return ( (LingualProtocolHandler) protocolHandler ).createLoadableTap( scheme, resource ); }
public ProtocolHandlers<Protocol, Format> getProtocolHandlers( SchemaDef schemaDef ) { if( schemaDef == null ) schemaDef = schemaCatalog.getRootSchemaDef(); return new ProtocolHandlers<Protocol, Format>( createProtocolHandlers( schemaDef ) ); }
public FormatHandlers<Protocol, Format> getFormatHandlersFor( SchemaDef schemaDef ) { if( schemaDef == null ) schemaDef = schemaCatalog.getRootSchemaDef(); return new FormatHandlers<Protocol, Format>( createFormatHandlers( schemaDef ) ); }