/** * Shuts down running components that were found by the service. */ public void shutdown() { // Stop the component monitoring service. if (executor != null) { executor.shutdown(); } // Shutdown found components. for (String subdomain : componentDomains.values()) { try { manager.removeComponent(subdomain); } catch (ComponentException e) { manager.getLog().error("Error shutting down component", e); } } components.clear(); componentDirs.clear(); classloaders.clear(); componentDomains.clear(); }
public void run() { synchronized (writer) { // Send heartbeat if no packet has been sent to the server for a given time if (System.currentTimeMillis() - lastActive >= 30000) { try { writer.write(" "); writer.flush(); } catch (IOException e) { // Log the exception manager.getLog().error(e); if (!shutdown) { // Connection was lost so try to reconnect connectionLost(); } } catch (Exception e) { // Do nothing } } } } }
manager.getLog().error(e);
/** * Returns the value of an element selected via an xpath expression from * a component's component.xml file. * * @param component the component. * @param xpath the xpath expression. * @return the value of the element selected by the xpath expression. */ private String getElementValue(Component component, String xpath) { File componentDir = componentDirs.get(component); if (componentDir == null) { return null; } try { File componentConfig = new File(componentDir, "component.xml"); if (componentConfig.exists()) { SAXReader saxReader = new SAXReader(); Document componentXML = saxReader.read(componentConfig); Element element = (Element)componentXML.selectSingleNode(xpath); if (element != null) { return element.getTextTrim(); } } } catch (Exception e) { manager.getLog().error(e); } return null; }
manager.getLog().error(e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return;
public void send(Packet packet) { synchronized (writer) { try { xmlSerializer.write(packet.getElement()); xmlSerializer.flush(); // Keep track of the last time a stanza was sent to the server lastActive = System.currentTimeMillis(); } catch (IOException e) { // Log the exception manager.getLog().error(e); if (!shutdown) { // Connection was lost so try to reconnect connectionLost(); } } } }
manager.removeComponent(componentDomains.get(component)); } catch (ComponentException e) { manager.getLog().error("Error shutting down component", e);
manager.getLog().error("Error unloading component " + componentName + ". " + "Will attempt again momentarily."); Thread.sleep(5000); System.gc(); while (!deleteDir(new File(componentDirectory, componentName))) { manager.getLog().error("Error unloading component " + componentName + ". " + "Will attempt again momentarily."); Thread.sleep(5000); manager.getLog().error(e);
public void run() { if (packet instanceof IQ) { IQ iq = (IQ) packet; IQ.Type iqType = iq.getType(); if (IQ.Type.result == iqType || IQ.Type.error == iqType) { // The server got an answer to an IQ packet that was sent from the component IQResultListener iqResultListener = resultListeners.remove(iq.getID()); resultTimeout.remove(iq.getID()); if (iqResultListener != null) { try { iqResultListener.receivedAnswer(iq); } catch (Exception e) { manager.getLog().error("Error processing answer of remote entity", e); } return; } } } component.processPacket(packet); } });
private void disconnect() { if (readerThread != null) { readerThread.shutdown(); } threadPool.shutdown(); TaskEngine.getInstance().cancelScheduledTask(keepAliveTask); TaskEngine.getInstance().cancelScheduledTask(timeoutTask); if (socket != null && !socket.isClosed()) { try { synchronized (writer) { try { writer.write("</stream:stream>"); xmlSerializer.flush(); } catch (IOException e) { // Do nothing } } } catch (Exception e) { // Do nothing } try { socket.close(); } catch (Exception e) { manager.getLog().error(e); } } }
manager.getLog().error("Error loading component: " + componentDir.getName(), e);
/** * A dedicated thread loop for reading the stream and sending incoming * packets to the appropriate router. */ public void run() { try { readStream(); } catch (EOFException eof) { // Normal disconnect } catch (SocketException se) { // Do nothing if the exception occured while shutting down the component otherwise // log the error and try to establish a new connection if (!shutdown) { component.getManager().getLog().error(se); component.connectionLost(); } } catch (XmlPullParserException ie) { component.getManager().getLog().error(ie); } catch (Exception e) { component.getManager().getLog().warn(e); } }
manager.getLog().error("Error trying to reconnect with the server", e);