@Override public void setHostResult(HostAndCommand hostAndCommand, HostResult result) { try { Log.warning("set host result "+ hostAndCommand +" from "+ getClientHost()); } catch (ServerNotActiveException snae) { snae.printStackTrace(); } activeHostCommands.remove(hostAndCommand); incompleteHostCommands.remove(hostAndCommand); completeHostCommands.add(hostAndCommand); if (incompleteHostCommands.size() == 0) { try { pendingHostCommands.put(DONE_MARKER); } catch (InterruptedException ie) { } if (terminateUponCompletion) { if (beginTermination()) { displayIncomplete(); } } else { displayIncomplete(); } } logState(); }
/** * Adds a feature to the ThreadGroup attribute of the RemoteJMeterEngineImpl * object. * * @param testTree * the feature to be added to the ThreadGroup attribute */ @Override public void rconfigure(HashTree testTree, String host, File jmxBase, String scriptName) throws RemoteException { log.info("Creating JMeter engine on host "+host+" base '"+jmxBase+"'"); try { log.info("Remote client host: " + getClientHost()); } catch (ServerNotActiveException e) { // ignored } synchronized(LOCK) { // close window where another remote client might jump in if (backingEngine != null && backingEngine.isActive()) { log.warn("Engine is busy - cannot create JMeter engine"); throw new IllegalStateException("Engine is busy - please try later"); } ownerThread = Thread.currentThread(); backingEngine = new StandardJMeterEngine(host); backingEngine.configure(testTree); // sets active = true } FileServer.getFileServer().setScriptName(scriptName); FileServer.getFileServer().setBase(jmxBase); }
@Override public String registra(String nombre, FileServer fl) throws RemoteException { String localizador = null; try { localizador = FileSearchImpl.getClientHost() + "/" + nombre; this.oremotos.put(localizador, fl); System.out.println("LOG: " + FileSearchImpl.class.getName() + ": registra(): " + localizador + "."); } catch (ServerNotActiveException ex) { /* Cliente desaparecido en combate */ System.out.println("LOG: " + FileSearchImpl.class.getName() + ": registra(): " + "Intento de registro por cliente no accesible."); } return localizador; }
@Override public boolean registerServer(String key, RMIServiceInterface service) throws RemoteException { for (ManagedServerInformationNode node : getServer().getServerConfig().getManagedServers().values()) { if (node.getServerKey().equals(key)) { try { // 注册服务 node.setRemoteService(service); node.setServerRMIAddress(service.getServerRMIAddress()); // 输出日志 logger.info( String.format("服务节点 [%s] 上线.服务地址为 [%s] .", node.getServerType(), RemoteServer.getClientHost())); return true; } catch (ServerNotActiveException ex) { logger.error("尝试注册服务失败:", ex); } } } return false; }
@Override public long createSession(String name, String password) throws java.rmi.RemoteException { try { validate(name, password); } catch (JDependException e1) { e1.printStackTrace(); throw new RemoteException(e1.getMessage(), e1); } JDependSession session = new JDependSession(); session.setId(UUID.randomUUID().getLeastSignificantBits()); session.setUserName(name); try { session.setClient(getClientHost()); } catch (ServerNotActiveException e) { e.printStackTrace(); } JDependSessionMgr.getInstance().putSession(session); return session.getId(); }
/** * notify all clients of state change. If connection fails, this will modify * client hashmaps. Therefore callers should not iterate directly over the * clientWaitingForAgent and clientWaitingForHuman arrays. * * @param newState * @throws RemoteException */ public void notifyStateChange(EnvironmentState newState) { // duplicate the set before iteration, since we may call // unregisterClient. Set<BW4TClientActions> clientset = new HashSet<>(this.clients.keySet()); for (BW4TClientActions client : clientset) { try { client.handleStateChange(newState); } catch (RemoteException e) { reportClientProblem(client, e); try { unregisterClient(client); } catch (ServerNotActiveException e1) { e1.printStackTrace(); } } } }
/** * Checks if the current client has privilegies to modify the contents of * the registry. All non-local clients should be rejected. * * @throws AccessException * if registry denies the caller access to perform this * operation */ private final void checkAccessPrivilegies() throws AccessException { String hostName; try { hostName = RemoteServer.getClientHost(); } catch (ServerNotActiveException e) { // if no remote host is currently executing this method, // then is localhost, and the access should be granted. return; } if (hostName == null) { throw new AccessException("Can not get remote host address."); } if (!localIPs.contains(hostName)) { throw new AccessException( "Registry can not be modified by this host."); } }
/** * Tests the hosts status. * * @param arguments an arbitrary number of hosts * @return a boolean value * @throws RemoteException if the remote operation fails */ public Object execute(Object... arguments) throws RemoteException { String host; String client; if ((Integer)arguments[0] > 1) { i++; host = (String) arguments[i]; } else { host = (String) arguments[1]; } try { client = getClientHost(); } catch (ServerNotActiveException e) { client = System.getProperty("java.rmi.server.hostname"); } if (host.equals(client)) { out.println("\t\tHost " + client + " work well"); return true; } else { out.println("\t\tHost " + client + " don't work, this host wasn't " + host); return false; } }
/** * Executes an object a specified number of times. * * @param obj a <code>ServerExecutor</code> * @param times of the executions * @param arguments an arbitrary number of hosts * @return a result of the execution * @throws RemoteException if the remote operation fails */ public Object execute(ServerExecutor obj, int times, Object... arguments) throws RemoteException { if (!imInServer()) { try { System.out.println("\t\tExcecuting execute client: " + getClientHost() + " my: " + ReportIPServer.localHost()); } catch (ServerNotActiveException e) { // TODO Auto-generated catch block e.printStackTrace(); } } for (int i = 0; i < times - 1; i++) { obj.execute(arguments); } return obj.execute(arguments); }
public int[][] sumMatrixAB() { if ((m1 == null)|| (m2 == null)) { throw new RuntimeException("Matrix not loaded"); } try { System.out.println("add Matrix called from "+getClientHost()); } catch (ServerNotActiveException e) { e.printStackTrace(); } int[][] result = new int[m1.length][m2.length]; int i, j; for (i = 0; i < m1.length; i++) { for (j = 0; j < m2.length; j++) { result [i][j] = m1 [i][j] + m2 [i][j]; } } System.out.println("Result Matrix (add)"); System.out.println(Arrays.toString(result[0])); System.out.println(Arrays.toString(result[1])); System.out.println(); return result; }
public BigInteger[][] sumMatrixAB() { if ((m1 == null)|| (m2 == null)) { throw new RuntimeException("Matrix not loaded"); } try { System.out.println("add Matrix called from "+getClientHost()); } catch (ServerNotActiveException e) { e.printStackTrace(); } BigInteger[][] result = new BigInteger[m1.length][m2.length]; int i, j; for (i = 0; i < m1.length; i++) { for (j = 0; j < m2.length; j++) { result [i][j] = m1 [i][j].add(m2 [i][j]); } } System.out.println("Result Matrix (add)"); System.out.println(Arrays.toString(result[0])); System.out.println(Arrays.toString(result[1])); System.out.println(); return result; }
/** * Tests the hosts status. * * @param arguments an arbitrary number of hosts * @return a boolean value * @throws RemoteExcpetion if the remote operation fails */ public Object execute(Object... arguments) throws RemoteException { String host; String client; if ((Integer)arguments[0] > 1) { host = (String) arguments[i++]; } else { host = (String) arguments[1]; } try { client = getClientHost(); } catch (ServerNotActiveException e) { client = System.getProperty("java.rmi.server.hostname"); } if (host.equals(client)) { out.println("\t\tHost " + client + " work well"); return true; } else { out.println("\t\tHost " + client + " don't work, this host wasn't " + host); return false; } }
public int[][] sumMatrixAB() { if ((m1 == null) || (m2 == null)) { throw new RuntimeException("Matrix not loaded"); } try { System.out.println("add Matrix called from " + getClientHost()); } catch (ServerNotActiveException e) { e.printStackTrace(); } int[][] result = new int[m1.length][m2.length]; int i, j; for (i = 0; i < m1.length; i++) { for (j = 0; j < m2.length; j++) { result[i][j] = m1[i][j] + m2[i][j]; } } System.out.println("Result Matrix (add)"); System.out.println(Arrays.toString(result[0])); System.out.println(Arrays.toString(result[1])); System.out.println(); return result; }
public BigInteger[][] sumMatrixAB() { if ((m1 == null) || (m2 == null)) { throw new RuntimeException("Matrix not loaded"); } try { System.out.println("add Matrix called from " + getClientHost()); } catch (ServerNotActiveException e) { e.printStackTrace(); } BigInteger[][] result = new BigInteger[m1.length][m2.length]; int i, j; for (i = 0; i < m1.length; i++) { for (j = 0; j < m2.length; j++) { result[i][j] = m1[i][j].add(m2[i][j]); } } System.out.println("Result Matrix (add)"); System.out.println(Arrays.toString(result[0])); System.out.println(Arrays.toString(result[1])); System.out.println(); return result; }
/** * @see edu.harvard.econcs.jopt.solver.server.ISolverServer#getSolver() */ public IRemoteMIPSolver getSolver() throws RemoteException { String client = "Unknown"; try { client = getClientHost(); } catch (ServerNotActiveException e) { logger.warn("Could not get client host: " + e.getMessage()); } logger.info("Creating Load Balancing Remote Solver for: " + client); return new BalancingRemoteMIPSolver(); }
/** * Returns the client host for the current thread's connection. Throws * ServerNotActiveException if no connection is active for this thread. */ public static String getClientHost() throws ServerNotActiveException { ConnectionHandler h = threadConnectionHandler.get(); if (h != null) { return h.getClientHost(); } else { throw new ServerNotActiveException("not in a remote call"); } }
/** * Log the details of an incoming call. The method parameter is either of * type java.lang.reflect.Method or java.rmi.server.Operation. */ private void logCall(Remote obj, Object method) { if (callLog.isLoggable(Log.VERBOSE)) { String clientHost; try { clientHost = getClientHost(); } catch (ServerNotActiveException snae) { clientHost = "(local)"; // shouldn't happen } callLog.log(Log.VERBOSE, "[" + clientHost + ": " + obj.getClass().getName() + ref.getObjID().toString() + ": " + method + "]"); } }
private static synchronized String makeConnectionId(String protocol, Subject subject) { connectionIdNumber++; String clientHost = ""; try { clientHost = RemoteServer.getClientHost(); /* * According to the rules specified in the javax.management.remote * package description, a numeric IPv6 address (detected by the * presence of otherwise forbidden ":" character) forming a part * of the connection id must be enclosed in square brackets. */ if (clientHost.contains(":")) { clientHost = "[" + clientHost + "]"; } } catch (ServerNotActiveException e) { logger.trace("makeConnectionId", "getClientHost", e); } final StringBuilder buf = new StringBuilder(); buf.append(protocol).append(":"); if (clientHost.length() > 0) buf.append("//").append(clientHost); buf.append(" "); if (subject != null) { Set<Principal> principals = subject.getPrincipals(); String sep = ""; for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) { Principal p = it.next(); String name = p.getName().replace(' ', '_').replace(';', ':'); buf.append(sep).append(name); sep = ";"; } } buf.append(" ").append(connectionIdNumber); if (logger.traceOn()) logger.trace("newConnectionId","connectionId="+buf); return buf.toString(); }
private String getClient() { try { return super.getClientHost(); } catch (ServerNotActiveException e) { return "[" + e.getMessage() + "]"; } }
protected String getClientHostStr() { try { return NaefTefService.instance().isRmiClientAuthenticationEnabled() ? getClientHost() : null; } catch (ServerNotActiveException snae) { throw new RuntimeException(snae); } }
@Override public void workerComplete() throws RemoteException { try { Log.warning("worker complete from "+ getClientHost()); } catch (ServerNotActiveException snae) { snae.printStackTrace(); } completedWorkers.release(); Log.warning("Worker complete: ", completedWorkers.availablePermits()); }
public String sayHello() throws RemoteException { try { System.out.println("LOG: "+ ServidorHola.class.getName() + ": registra(): "+ getClientHost() ); } catch (ServerNotActiveException e) { e.printStackTrace(); } return "Hola, mundo!"; }