use of java.net.SocketException in project zookeeper by apache.
the class QuorumPeer method startLeaderElection.
public synchronized void startLeaderElection() {
try {
if (getPeerState() == ServerState.LOOKING) {
currentVote = new Vote(myid, getLastLoggedZxid(), getCurrentEpoch());
}
} catch (IOException e) {
RuntimeException re = new RuntimeException(e.getMessage());
re.setStackTrace(e.getStackTrace());
throw re;
}
//}
if (electionType == 0) {
try {
udpSocket = new DatagramSocket(myQuorumAddr.getPort());
responder = new ResponderThread();
responder.start();
} catch (SocketException e) {
throw new RuntimeException(e);
}
}
this.electionAlg = createElectionAlgorithm(electionType);
}
use of java.net.SocketException in project weave by continuuity.
the class SocketServer method run.
@Override
public void run() {
try {
runThread = Thread.currentThread();
while (running) {
try {
Socket socket = serverSocket.accept();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
handleRequest(reader, writer);
} finally {
socket.close();
}
} catch (SocketException e) {
LOG.info("Socket exception: " + e);
}
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
use of java.net.SocketException in project cw-omnibus by commonsguy.
the class WebServerService method raiseReadyEvent.
private void raiseReadyEvent() {
ServerStartedEvent event = new ServerStartedEvent();
try {
for (Enumeration<NetworkInterface> enInterfaces = NetworkInterface.getNetworkInterfaces(); enInterfaces.hasMoreElements(); ) {
NetworkInterface ni = enInterfaces.nextElement();
for (Enumeration<InetAddress> enAddresses = ni.getInetAddresses(); enAddresses.hasMoreElements(); ) {
InetAddress addr = enAddresses.nextElement();
if (addr instanceof Inet4Address) {
event.addUrl("http://" + addr.getHostAddress() + ":4999" + rootPath + "/");
}
}
}
} catch (SocketException ex) {
ex.printStackTrace();
}
EventBus.getDefault().removeAllStickyEvents();
EventBus.getDefault().postSticky(event);
}
use of java.net.SocketException in project cw-omnibus by commonsguy.
the class WebServerService method raiseReadyEvent.
private void raiseReadyEvent() {
ServerStartedEvent event = new ServerStartedEvent();
try {
for (Enumeration<NetworkInterface> enInterfaces = NetworkInterface.getNetworkInterfaces(); enInterfaces.hasMoreElements(); ) {
NetworkInterface ni = enInterfaces.nextElement();
for (Enumeration<InetAddress> enAddresses = ni.getInetAddresses(); enAddresses.hasMoreElements(); ) {
InetAddress addr = enAddresses.nextElement();
if (addr instanceof Inet4Address) {
event.addUrl("http://" + addr.getHostAddress() + ":4999" + rootPath + "/");
}
}
}
} catch (SocketException ex) {
ex.printStackTrace();
}
EventBus.getDefault().removeAllStickyEvents();
EventBus.getDefault().postSticky(event);
}
use of java.net.SocketException in project cw-omnibus by commonsguy.
the class WebServerService method raiseStartedEvent.
private void raiseStartedEvent() {
ServerStartedEvent event = new ServerStartedEvent();
try {
for (Enumeration<NetworkInterface> enInterfaces = NetworkInterface.getNetworkInterfaces(); enInterfaces.hasMoreElements(); ) {
NetworkInterface ni = enInterfaces.nextElement();
for (Enumeration<InetAddress> enAddresses = ni.getInetAddresses(); enAddresses.hasMoreElements(); ) {
InetAddress addr = enAddresses.nextElement();
if (addr instanceof Inet4Address) {
event.addUrl("http://" + addr.getHostAddress() + ":4999");
}
}
}
} catch (SocketException e) {
Log.e(getClass().getSimpleName(), "Exception in IP addresses", e);
}
EventBus.getDefault().removeAllStickyEvents();
EventBus.getDefault().postSticky(event);
}
Aggregations