/** * @see stream.urls.Connection#connect() */ @Override public InputStream connect() throws IOException { if (stream == null) { Configuration config = new Configuration(); FileSystem fs = FileSystem.get(URI.create(url.toString()), config); stream = fs.open(new Path(url.toString())); } return stream; }
@Override public void init() throws Exception { if (filesAreRead.getAndSet(false)) { log.debug("Initializing directory stream with URL '{}'", url.toString()); log.debug(" file path of URL is: {}", url.getFile()); dir = new File(url.getFile()); // dir = new File(new URI(url.toString())); if (!dir.isDirectory()) throw new IllegalArgumentException("Directory not found"); dirPath = dir.getAbsolutePath(); files = dir.list(); counter = new AtomicInteger(0); } }
@Override public void init() throws Exception { if (filesAreRead.getAndSet(false)) { log.debug("Initializing directory stream with URL '{}'", url.toString()); log.debug(" file path of URL is: {}", url.getFile()); dir = new File(url.getFile()); // dir = new File(new URI(url.toString())); if (!dir.isDirectory()) throw new IllegalArgumentException("Directory not found"); dirPath = dir.getAbsolutePath(); files = dir.list(); counter = new AtomicInteger(0); } }
String theUrl = url.toString();
/** * @see stream.runtime.LifeCycle#init(stream.Context) */ @Override public void init(ApplicationContext context) throws Exception { try { log.info("Opening connection to database {}", getUrl()); SourceURL url = this.getUrl(); connection = DriverManager.getConnection(url.toString(), getUsername(), getPassword()); statement = connection.prepareStatement(select); } catch (Exception e) { log.error("Failed to connect to database: {}", e.getMessage()); e.printStackTrace(); } }
/** * @see stream.runtime.LifeCycle#init(stream.Context) */ @Override public void init(ApplicationContext context) throws Exception { try { log.info("Opening connection to database {}", getUrl()); SourceURL url = this.getUrl(); connection = DriverManager.getConnection(url.toString(), getUsername(), getPassword()); statement = connection.prepareStatement(select); } catch (Exception e) { log.error("Failed to connect to database: {}", e.getMessage()); e.printStackTrace(); } }
/** * @see stream.io.AbstractStream#init() */ @Override public void init() throws Exception { super.init(); try { log.info("Opening connection to database {}", getUrl()); SourceURL url = this.getUrl(); connection = DriverManager.getConnection(url.toString(), getUsername(), getPassword()); PreparedStatement stmt = connection.prepareStatement(select); result = stmt.executeQuery(); } catch (Exception e) { log.error("Failed to connect to database: {}", e.getMessage()); e.printStackTrace(); } }
/** * @see stream.io.AbstractStream#init() */ @Override public void init() throws Exception { super.init(); try { log.info("Opening connection to database {}", getUrl()); SourceURL url = this.getUrl(); connection = DriverManager.getConnection(url.toString(), getUsername(), getPassword()); PreparedStatement stmt = connection.prepareStatement(select); result = stmt.executeQuery(); } catch (Exception e) { log.error("Failed to connect to database: {}", e.getMessage()); e.printStackTrace(); } }
SourceURL surl = createUrl(f); stream.setUrl(surl); log.info("Set Url:{}", surl.toString()); stream.init();
SourceURL surl = createUrl(f); stream.setUrl(surl); log.info("Set Url:{}", surl.toString()); stream.init();