org.eclipse.jetty.io.RuntimeIOException Java Examples

The following examples show how to use org.eclipse.jetty.io.RuntimeIOException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricDataRowCallbackHandler.java    From graphouse with Apache License 2.0 6 votes vote down vote up
@Override
public void processRow(ResultSet rs) throws SQLException {
    try {
        String metric = rs.getString("metric");
        int ts = rs.getInt("ts");
        double value = rs.getDouble("value");
        checkNewMetric(metric);
        fillNulls(ts);
        if (Double.isFinite(value)) {
            jsonWriter.value(value);
            nextTs = ts + queryParams.getStepSeconds();
        }
    } catch (IOException e) {
        log.error("Failed to read data from CH", e);
        throw new RuntimeIOException(e);
    }
}
 
Example #2
Source File: CatStream.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void findReadableFiles(CrawlFile seed, List<CrawlFile> foundFiles) {

    final Path entry = seed.absolutePath;

    // Skip over paths that don't exist or that are symbolic links
    if ((!Files.exists(entry)) || (!Files.isReadable(entry)) || Files.isSymbolicLink(entry)) {
      return;
    }

    // We already know that the path in question exists, is readable, and is in our sandbox
    if (Files.isRegularFile(entry)) {
      foundFiles.add(seed);
    } else if (Files.isDirectory(entry)) {
      try (Stream<Path> directoryContents = Files.list(entry)) {
        directoryContents.sorted().forEach(iPath -> {
          // debatable: should the separator be OS/file-system specific, or perhaps always "/" ?
          final String displayPathSeparator = iPath.getFileSystem().getSeparator();
          final String itemDisplayPath = seed.displayPath + displayPathSeparator + iPath.getFileName();
          findReadableFiles(new CrawlFile(itemDisplayPath, iPath), foundFiles);
        });
      } catch (IOException e) {
        throw new RuntimeIOException(e);
      }
    }
  }
 
Example #3
Source File: FirmataProtocolHandler.java    From diozero with MIT License 6 votes vote down vote up
public FirmataProtocolHandler(RemoteDeviceFactory deviceFactory) {
	this.deviceFactory = deviceFactory;
	
	String hostname = PropertyUtil.getProperty(TCP_HOST_PROP, null);
	if (hostname != null) {
		int port = PropertyUtil.getIntProperty(TCP_PORT_PROP, DEFAULT_TCP_PORT);
		try {
			adapter = new SocketFirmataAdapter(this, hostname, port);
		} catch (IOException e) {
			throw new RuntimeIOException(e);
		}
		// } else {
		// String serial_port = PropertyUtil.getProperty(SERIAL_PORT_PROP, null);
		// if (serial_port != null) {
		// adapter = new SerialFirmataAdapter(serial_port)
		// }
	}
	if (adapter == null) {
		Logger.error("Please set either {} or {} property", TCP_HOST_PROP, SERIAL_PORT_PROP);
		throw new IllegalArgumentException("Either " + TCP_HOST_PROP + " or " + SERIAL_PORT_PROP + " must be set");
	}
}
 
Example #4
Source File: WebsocketServerInitiatedPingTest.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void onWebSocketConnect(Session sess) {
  super.onWebSocketConnect(sess);
  try {
    Thread.sleep(1000);
  } catch (Exception e) {
  }
  final String textMessage = "PingPong";
  final ByteBuffer binaryMessage = ByteBuffer.wrap(
             textMessage.getBytes(StandardCharsets.UTF_8));

  try {
    RemoteEndpoint remote = getRemote();
    remote.sendPing(binaryMessage);
    if (remote.getBatchMode() == BatchMode.ON) {
      remote.flush();
    }
  } catch (IOException x) {
    throw new RuntimeIOException(x);
  }
}
 
Example #5
Source File: BadSocket.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void onWebSocketBinary(byte[] payload, int offset, int len) {
  if (isNotConnected()) {
    return;
  }

  try {
    RemoteEndpoint remote = getRemote();
    remote.sendBytes(BufferUtil.toBuffer(payload, offset, len), null);
    if (remote.getBatchMode() == BatchMode.ON) {
      remote.flush();
    }
  } catch (IOException x) {
    throw new RuntimeIOException(x);
  }
}
 
Example #6
Source File: EchoSocket.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void onWebSocketBinary(byte[] payload, int offset, int len) {
  if (isNotConnected()) {
    return;
  }

  try {
    RemoteEndpoint remote = getRemote();
    remote.sendBytes(BufferUtil.toBuffer(payload, offset, len), null);
    if (remote.getBatchMode() == BatchMode.ON) {
      remote.flush();
    }
  } catch (IOException x) {
    throw new RuntimeIOException(x);
  }
}
 
Example #7
Source File: EchoSocket.java    From knox with Apache License 2.0 6 votes vote down vote up
@Override
public void onWebSocketText(String message) {
  if (isNotConnected()) {
    return;
  }

  try {
    RemoteEndpoint remote = getRemote();
    remote.sendString(message, null);
    if (remote.getBatchMode() == BatchMode.ON) {
      remote.flush();
    }
  } catch (IOException x) {
    throw new RuntimeIOException(x);
  }
}
 
Example #8
Source File: MirusSourceConnector.java    From mirus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String readVersion() {
  try {
    URL url = Resources.getResource(MirusSourceConnector.class, "mirus-version.txt");
    return Resources.toString(url, Charsets.UTF_8);
  } catch (IOException e) {
    throw new RuntimeIOException(e);
  }
}
 
Example #9
Source File: MetricDataRowCallbackHandler.java    From graphouse with Apache License 2.0 5 votes vote down vote up
public void finish() {
    try {
        endMetric();
        Iterator<String> remainingMetricIterator = remainingMetrics.iterator();
        while (remainingMetricIterator.hasNext()) {
            String remainingMetric = remainingMetricIterator.next();
            remainingMetricIterator.remove();
            startMetric(remainingMetric);
            endMetric();
        }
    } catch (IOException e) {
        log.error("Failed to read data from CH", e);
        throw new RuntimeIOException(e);
    }
}
 
Example #10
Source File: MustacheTemplateEngine.java    From spark-template-engines with Apache License 2.0 5 votes vote down vote up
@Override
public String render(ModelAndView modelAndView) {
    String viewName = modelAndView.getViewName();
    Mustache mustache = mustacheFactory.compile(viewName);
    StringWriter stringWriter = new StringWriter();
    try {
        mustache.execute(stringWriter, modelAndView.getModel()).close();
    } catch (IOException e) {
        throw new RuntimeIOException(e);
    }
    return stringWriter.toString();
}
 
Example #11
Source File: HandlebarsTemplateEngine.java    From spark-template-engines with Apache License 2.0 5 votes vote down vote up
@Override
public String render(ModelAndView modelAndView) {
    String viewName = modelAndView.getViewName();
    try {
        Template template = handlebars.compile(viewName);
        return template.apply(modelAndView.getModel());
    } catch (IOException e) {
        throw new RuntimeIOException(e);
    }
}
 
Example #12
Source File: WebsocketServerInitiatedMessageTest.java    From knox with Apache License 2.0 5 votes vote down vote up
@Override
public void onWebSocketConnect(Session sess) {
  super.onWebSocketConnect(sess);

  try {
    RemoteEndpoint remote = getRemote();
    remote.sendString("echo", null);
    if (remote.getBatchMode() == BatchMode.ON) {
      remote.flush();
    }
  } catch (IOException x) {
    throw new RuntimeIOException(x);
  }
}
 
Example #13
Source File: GitDeltaConsumer.java    From git-as-svn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void close() {
  try {
    super.close();
  } catch (IOException e) {
    throw new RuntimeIOException(e);
  }
}
 
Example #14
Source File: Demo_JettyWebSocketClient.java    From haxademic with MIT License 5 votes vote down vote up
protected void firstFrame() {
        try {
        	// web socket
        	HttpClient http = new HttpClient();
        	http.start();
            WebSocketClient websocket = new WebSocketClient(http);
            websocket.start();
        	try {

        		URI uri = new URI("ws://localhost:8787/websocket");
        		P.out("Connecting to: {}...", uri);
        		Session session = websocket.connect(new ToUpper356ClientSocket(), uri, new ClientUpgradeRequest()).get();
        		P.out("Connected to: {}", uri);
        		remote = session.getRemote();
        		remote.sendString("Hello World");
        	} catch (Exception e) {
        		throw new RuntimeIOException(e);
        	}
        	
//        	ClientUpgradeRequest request = new ClientUpgradeRequest();
//        	
//        	HttpClient http = new HttpClient();
//        	http.start();
//            WebSocketClient websocket = new WebSocketClient(http);
//            websocket.start();
//            try
//            {
//                String dest = "ws://localhost:8787/";
//                websocket.connect(new ToUpper356ClientSocket(), new URI(dest), request);
//            }
//            finally
//            {
//                websocket.stop();
//            } 
        } catch (Throwable t) {
            t.printStackTrace();
        }

	}