Search in sources :

Example 1 with SocketServerInputStreamFactory

use of org.apache.asterix.external.input.stream.factory.SocketServerInputStreamFactory in project asterixdb by apache.

the class DatasourceFactoryProvider method getInputStreamFactory.

public static IInputStreamFactory getInputStreamFactory(ILibraryManager libraryManager, String streamSource, Map<String, String> configuration) throws HyracksDataException {
    IInputStreamFactory streamSourceFactory;
    if (ExternalDataUtils.isExternal(streamSource)) {
        String dataverse = ExternalDataUtils.getDataverse(configuration);
        streamSourceFactory = ExternalDataUtils.createExternalInputStreamFactory(libraryManager, dataverse, streamSource);
    } else {
        switch(streamSource) {
            case ExternalDataConstants.STREAM_LOCAL_FILESYSTEM:
                streamSourceFactory = new LocalFSInputStreamFactory();
                break;
            case ExternalDataConstants.SOCKET:
            case ExternalDataConstants.ALIAS_SOCKET_ADAPTER:
                streamSourceFactory = new SocketServerInputStreamFactory();
                break;
            case ExternalDataConstants.STREAM_SOCKET_CLIENT:
                streamSourceFactory = new SocketServerInputStreamFactory();
                break;
            default:
                try {
                    streamSourceFactory = (IInputStreamFactory) Class.forName(streamSource).newInstance();
                } catch (Exception e) {
                    throw new RuntimeDataException(ErrorCode.PROVIDER_DATASOURCE_FACTORY_UNKNOWN_INPUT_STREAM_FACTORY, e, streamSource);
                }
        }
    }
    return streamSourceFactory;
}
Also used : LocalFSInputStreamFactory(org.apache.asterix.external.input.stream.factory.LocalFSInputStreamFactory) IInputStreamFactory(org.apache.asterix.external.api.IInputStreamFactory) SocketServerInputStreamFactory(org.apache.asterix.external.input.stream.factory.SocketServerInputStreamFactory) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IOException(java.io.IOException) AsterixException(org.apache.asterix.common.exceptions.AsterixException) RuntimeDataException(org.apache.asterix.common.exceptions.RuntimeDataException)

Aggregations

IOException (java.io.IOException)1 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 RuntimeDataException (org.apache.asterix.common.exceptions.RuntimeDataException)1 IInputStreamFactory (org.apache.asterix.external.api.IInputStreamFactory)1 LocalFSInputStreamFactory (org.apache.asterix.external.input.stream.factory.LocalFSInputStreamFactory)1 SocketServerInputStreamFactory (org.apache.asterix.external.input.stream.factory.SocketServerInputStreamFactory)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1