@Override public void checkOutputSpecs(JobContext context) throws IOException, InterruptedException { String[] hosts = conf.getStrings(OUTPUT_HOST); if (hosts == null || hosts.length == 0) { throw new IllegalStateException(OUTPUT_HOST + " is not specified."); } for (int i = 0; i < hosts.length; i++) { try { ContentSource cs = InternalUtilities.getOutputContentSource(conf, hosts[i]); checkOutputSpecs(conf, cs); return; } catch (Exception ex) { if (ex.getCause() instanceof ServerConnectionException) { LOG.warn("Unable to connect to " + hosts[i] + " to query destination information"); continue; } else { throw new IOException(ex); } } } // No usable output hostname found at this point throw new IOException("Unable to query destination information," + " no usable hostname found"); }
/** * Get the session for this writer. One writer only maintains one session. * * @return Session for this writer. * @throws IOException */ protected Session getSession() throws IOException { if (session == null) { // start a session try { ContentSource cs = InternalUtilities.getOutputContentSource( conf, hostName); session = cs.newSession(); if (LOG.isDebugEnabled()) { LOG.debug("Connect to " + session.getConnectionUri().getHost()); } if (txnSize > 1) { session.setTransactionMode(TransactionMode.UPDATE); } } catch (XccConfigException e) { LOG.error("Error creating a new session: ", e); throw new IOException(e); } } return session; }
protected void submitGraphQuery() throws IOException{ Session session = null; ContentSource cs; try { cs = InternalUtilities.getOutputContentSource(conf, conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]); session = cs.newSession(); RequestOptions options = new RequestOptions(); options.setDefaultXQueryVersion("1.0-ml"); session.setDefaultRequestOptions(options); AdhocQuery query = session.newAdhocQuery(graphQry.toString()); if(LOG.isDebugEnabled()) { LOG.debug(graphQry.toString()); } query.setOptions(options); session.submitRequest(query); } catch (RequestException e) { throw new IOException(e); } catch (XccConfigException e) { throw new IOException(e); } finally { if (session != null) { session.close(); } } } @Override
ContentSource cs = sourceMap.get(targetHost); if (cs == null) { cs = InternalUtilities.getOutputContentSource( conf, targetHost); sourceMap.put(targetHost, cs); String hostStr = host.toString(); try { ContentSource cs = InternalUtilities.getOutputContentSource( conf, hostStr); sourceMap.put(hostStr, cs);
ContentSource cs; try { cs = InternalUtilities.getOutputContentSource(conf, conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]); session = cs.newSession();
try { String host = hosts[i]; ContentSource cs = InternalUtilities.getOutputContentSource(conf, host); session = cs.newSession();
ContentSource cs; try { cs = InternalUtilities.getOutputContentSource(conf, conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]);
while (hostIdx < outputHosts.length) { try { cs = InternalUtilities.getOutputContentSource(conf, outputHosts[hostIdx]); session = cs.newSession("Security");