List of usage examples for java.rmi RemoteException RemoteException
public RemoteException(String s)
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
public String getVMsByState(String state) throws RemoteException { try {// w ww .j av a 2s . co m VM[] vms = manager.getGlobalAll(); final List<VMTranslation> vmts = new ArrayList<VMTranslation>(); for (VM vm : vms) { if (vm.getState().getState().equalsIgnoreCase(state)) vmts.add(translateVM(vm)); } if (vmts.size() == 0) return null; return gson.toJson(vmts); } catch (ManageException e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
public Hashtable<String, String[]> showVMsForAllHosts() throws RemoteException { try {/*from w ww . ja va 2 s . c o m*/ List<String> hostnames = new ArrayList<String>(); VM[] vms = manager.getGlobalAll(); if (vms.length == 0) return null; for (int i = 0; i < vms.length; i++) { String id = vms[i].getID(); String host = workspaceHome.find(id).getVM().getNode(); if (!hostnames.contains(host)) hostnames.add(host); } Hashtable<String, String[]> allVMs = new Hashtable<String, String[]>(); for (String hostname : hostnames) { vms = getVMByHost(hostname); String[] parsedVMs = new String[vms.length]; for (int i = 0; i < vms.length; i++) { parsedVMs[i] = vms[i].getID(); } allVMs.put(hostname, parsedVMs); } return allVMs; } catch (ManageException e) { throw new RemoteException(e.getMessage()); } catch (DoesNotExistException e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
public String shutdown(int type, String typeID, String seconds, boolean force) throws RemoteException { try {/* www . j a v a2s. c o m*/ VM[] vms; String returnMsg = null; vms = typeSet(type, typeID); if (vms == null || vms.length == 0) return errorMsg; for (int i = 0; i < vms.length; i++) { String id = vms[i].getID(); Caller caller = vms[i].getCreator(); try { manager.shutdown(id, manager.INSTANCE, null, caller); } catch (OperationDisabledException e) { logger.warn("Shutdown is currently disabled for instance " + id); if (returnMsg == null) { returnMsg = "Shutdown is currently disabled for instance " + id; } else { returnMsg += "\nShutdown is currently disabled for instance " + id; } } } //checks every 3 seconds to see if one of the vms has entered propagation mode //up to a max of 30 seconds before trashing all vms //I decided against checking every single vm for entering propagation mode since they mostly enter at //about the same speed if (seconds == null) { for (int i = 0; i <= 10; i++) { Thread.sleep(3000); vms = typeSet(type, typeID); if (vms[0].getState().getState().equals("Propagated")) break; } } //same as above, but max time is the amount of seconds entered by the user else { int mill = (Integer.parseInt(seconds)) * 1000; for (int i = 0; i <= mill; i += 3000) { Thread.sleep(3000); vms = typeSet(type, typeID); if (vms[0].getState().getState().equals("Propagated")) break; } } //eventually trashes all vms regardless of whether or not they enter propagation mode vms = typeSet(type, typeID); for (int i = 0; i < vms.length; i++) { String id = vms[i].getID(); Caller caller = vms[i].getCreator(); if (force || vms[i].getState().getState().equals("Propagated")) { manager.trash(id, manager.INSTANCE, caller); } else { if (returnMsg == null) { returnMsg = "Instance " + id + " not trashed because it is was not shut down correctly and --force is off"; } else { returnMsg += "\nInstance " + id + " not trashed because it is was not shut down correctly and --force is off"; } } } return returnMsg; } catch (ManageException e) { throw new RemoteException(e.getMessage()); } catch (DoesNotExistException e) { throw new RemoteException(e.getMessage()); } catch (InterruptedException e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
public String cleanup(int type, String typeID) throws RemoteException { try {//from w w w . ja v a2 s . c om VM[] vms; vms = typeSet(type, typeID); if (vms == null || vms.length == 0) return errorMsg; for (int i = 0; i < vms.length; i++) { String id = vms[i].getID(); Caller caller = vms[i].getCreator(); manager.cleanup(id, manager.INSTANCE, caller); } return null; } catch (ManageException e) { throw new RemoteException(e.getMessage()); } catch (DoesNotExistException e) { throw new RemoteException(e.getMessage()); } catch (OperationDisabledException e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
private VM[] typeSet(int type, String typeID) throws RemoteException { try {/* w ww . j a v a 2s. c om*/ if (type == SHUTDOWN_HOST || type == CLEANUP_HOST) return getVMByHost(typeID); else if (type == SHUTDOWN_ID || type == CLEANUP_ID) return getVMById(typeID); else if (type == SHUTDOWN_UNAME || type == CLEANUP_UNAME) { authz = new AuthzDBAdapter(authzDataSource); String userId = authz.getCanonicalUserIdFromFriendlyName(typeID); VM[] vms = getVMsByUserId(userId); if (vms == null) errorMsg = "No VMs with user name " + typeID + " found"; return vms; } else if (type == SHUTDOWN_DN || type == CLEANUP_DN) { final _Caller caller = this.reprFactory._newCaller(); caller.setIdentity(typeID); VM[] vms = manager.getAllByCaller(caller); if (vms.length == 0) errorMsg = "No VMs with DN " + typeID + " found"; return vms; } else if (type == SHUTDOWN_GID || type == CLEANUP_GID) { Group group = getGroupByGroupId(typeID); if (group == null) return null; VM[] vms = getAllVMsByGroup(group); if (vms == null) errorMsg = "No VMs with group id " + typeID + " found"; return vms; } else if (type == SHUTDOWN_GNAME || type == CLEANUP_GNAME) { Group group = getGroupByGroupName(typeID); if (group == null) return null; VM[] vms = getAllVMsByGroup(group); if (vms == null) errorMsg = "No VMs with group name " + typeID + " found"; return vms; } else { VM[] vms = manager.getGlobalAll(); if (vms.length == 0) errorMsg = "No running VMs available for shutdown or cleanup"; return vms; } } catch (ManageException e) { throw new RemoteException(e.getMessage()); } catch (AuthzDBException e) { errorMsg = "User " + typeID + " does not exist"; return null; } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
private VM[] getVMsByUserId(String userId) throws RemoteException { try {/*from ww w. ja v a2s. c om*/ List<UserAlias> userAlias; userAlias = authz.getUserAliases(userId); List<UserAlias> dnAlias = new ArrayList<UserAlias>(userAlias.size()); for (int i = 0; i < userAlias.size(); i++) { if (userAlias.get(i).getAliasType() == AuthzDBAdapter.ALIAS_TYPE_DN) dnAlias.add(userAlias.get(i)); } if (dnAlias.size() == 0) { return null; } else if (dnAlias.size() > 1) throw new RemoteException("User_Alias size: " + dnAlias.size()); String aliasDN = dnAlias.get(0).getAliasName(); final _Caller caller = this.reprFactory._newCaller(); caller.setIdentity(aliasDN); VM[] vmsByCaller = manager.getAllByCaller(caller); return vmsByCaller; } catch (AuthzDBException e) { throw new RemoteException(e.getMessage()); } catch (ManageException e) { return null; } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
private VM[] getAllVMsByGroup(Group group) throws RemoteException { try {/*w w w. j av a 2s .c o m*/ if (group != null) { String[] dns = group.getIdentities(); if (dns == null || dns.length == 0) return null; authz = new AuthzDBAdapter(authzDataSource); ArrayList<VM> allVMs = new ArrayList<VM>(0); for (int i = 0; i < dns.length; i++) { final _Caller caller = this.reprFactory._newCaller(); caller.setIdentity(dns[i]); VM[] vmsByCaller = manager.getAllByCaller(caller); for (int j = 0; j < vmsByCaller.length; j++) { allVMs.add(vmsByCaller[j]); } } if (allVMs.size() == 0) return null; VM[] vms = new VM[allVMs.size()]; return allVMs.toArray(vms); } return null; } catch (ManageException e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt.java
private VMTranslation translateVM(VM vm) throws RemoteException { try {/*from ww w . j a v a2 s. c o m*/ GroupAuthz groupAuthz = (GroupAuthz) authzCallout; String id = vm.getID(); VirtualMachine vmlong = workspaceHome.find(id).getVM(); String node = vmlong.getNode(); String creatorId = vm.getCreator().getIdentity(); String groupId = Integer.toString(groupAuthz.getGroupIDFromCaller(creatorId)); String groupName = groupAuthz.getGroupName(creatorId); String state = vm.getState().getState(); String startTime = vm.getSchedule().getStartTime().getTime().toString(); String endTime = vm.getSchedule().getDestructionTime().getTime().toString(); ResourceAllocation ra = vm.getResourceAllocation(); String memory = Integer.toString(ra.getMemory()); String cpuCount = Integer.toString(ra.getIndCpuCount()); String uri = vm.getVMFiles()[0].getURI().getPath(); VMTranslation vmt = new VMTranslation(id, node, creatorId, groupId, groupName, state, startTime, endTime, memory, cpuCount, uri); return vmt; } catch (ManageException e) { throw new RemoteException(e.getMessage()); } catch (DoesNotExistException e) { throw new RemoteException(e.getMessage()); } catch (Exception e) { throw new RemoteException(e.getMessage()); } }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteNodeManagement.java
public String addNodes(String nodeJson) throws RemoteException { if (nodeJson == null) { throw new IllegalArgumentException("nodeJson may not be null"); }//from w ww . j av a 2 s .com Collection<VmmNode> nodes = gson.fromJson(nodeJson, vmmNodeCollectionTypeToken.getType()); if (nodes == null || nodes.isEmpty()) { throw new IllegalArgumentException("you must specify at least one node to add"); } List<NodeReport> reports = new ArrayList<NodeReport>(nodes.size()); for (VmmNode node : nodes) { String hostname = node.getHostname(); if (hostname == null) { throw new IllegalArgumentException("hostname may not be null"); } logger.info("Adding VMM node " + hostname); try { final ResourcepoolEntry entry = nodeManagement.addNode(hostname, node.getPoolName(), node.getNetworkAssociations(), node.getMemory(), node.isActive()); final VmmNode resultNode = translateResourcepoolEntry(entry); reports.add(new NodeReport(hostname, NodeReport.STATE_ADDED, resultNode)); } catch (NodeExistsException e) { logger.info("VMM node " + hostname + " already existed"); reports.add(new NodeReport(hostname, NodeReport.STATE_NODE_EXISTS, null)); } catch (NodeManagementDisabled e) { throw new RemoteException(e.getMessage()); } catch (WorkspaceDatabaseException e) { throw new RemoteException(e.getMessage()); } } return gson.toJson(reports); }
From source file:org.globus.workspace.remoting.admin.defaults.DefaultRemoteNodeManagement.java
/** * If a mgmt ooperation is attempted and there is no active node management instance, * return a disabled message./*from w w w. java2 s .c o m*/ */ private void checkActive() throws RemoteException { if (this.nodeManagement == null) { throw new RemoteException("Remote node administration is disabled. " + "Are you in pilot mode?"); } }