//i've encapsulated the sorting code in a method that receives a list as a parameter. private List<Domain> sortDomains1(final List<Domain> domains) { //this is a tempList that will be returned from subList method. List<Domain> tempList = null; //as your using iterator anonymously, you have to implement an index int i = 0; for(final Domain domain : domains) { //looking for 'Hilton'. if(domain.getName().equalsIgnoreCase("Hilton")) { //here we're getting a sublist of 2 elements that need to be switched in positions tempList = domains.subList(i, i+2); //have to get 2 elements break; //if we'have found it, then we leaven the loop and switch positions; } //increasing an index of the array i++; } //having a subList we can change the order. It will also change it in the original list. Domain tempDomain; //we have to make a switch, so we need a temp Domain. tempDomain = tempList.get(1); //the one after hilton will be temp. tempList.set(1, tempList.get(0)); //put hilton in second position tempList.set(0, tempDomain); //put temp in first. return domains; }
List<Domain> dmn = new ArrayList<Domain>(); Iterator<Domain> it = dmn.iterator(); while(it.hasNext()){ Domain dom = it.next(); if(dom.getName().equalsIgnoreCase("Hilton") && it.hasNext()) { // prevents problems if "Hilton" is the last element { Domain domAfter = it.next(); System.out.println(domAfter); //do something with the next after Hilton first System.out.println(dom); //do something with Hilton then } else System.out.println(dom); //else do something with the current element }
public MessagesRpcServiceImpl() { super(); theUserManager = UserManagerFactory.getInstance().getUserManager(); theUserManager.getUserActivityScheduler().addTimeoutListener(new UserTimeoutListener() { @Override public void onTimeout(UserInfo arg0) { List<String> ids = new ArrayList<String>(); for (Domain d : er.getListenDomains()) { ids.add(d.getName()); } ids.remove("GLOBAL"); } }); }
logger(clazz, "job started"); List<Domain> domains = new ArrayList<>(); domains.addAll(domManager.getActiveDoms()); for (Domain d : domains) { try { Attributes attributes = iDirC.getAttributes("dns:/" + d.getName(), new String[] { "MX" }); Attribute attributeMX = attributes.get("MX"); System.out.println(attributes); } catch (NamingException e) { //do somethig here like `System.out.println("error message!");` } }
public static boolean isDefaultLocalNode(Node node) { Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getComponent(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } return false; }
public static boolean isDefaultLocalNode(Node node) { Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getService(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } return false; }
public static boolean isLocal(Node node) { // Short circuit common case for efficiency Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getService(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } String nodeHost = node.getNodeHost(); if (nodeHost == null || nodeHost.length() == 0) { return false; } return NetUtils.isThisHostLocal(nodeHost); }
public static boolean isLocal(Node node) { // Short circuit common case for efficiency Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getComponent(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } String nodeHost = node.getNodeHost(); if (nodeHost == null || nodeHost.length() == 0) { return false; } return NetUtils.isThisHostLocal(nodeHost); }
public static Node getDefaultLocalNode(Nodes nodes) { if (nodes == null) { return null; } Dom serverDom = Dom.unwrap(nodes); Domain domain = serverDom.getHabitat().getComponent(Domain.class); for (Node node : nodes.getNode()) { if (node.getName().equals("localhost-"+domain.getName())) { return node; } } return null; } }
public static Node getDefaultLocalNode(Nodes nodes) { if (nodes == null) { return null; } Dom serverDom = Dom.unwrap(nodes); Domain domain = serverDom.getHabitat().getService(Domain.class); for (Node node : nodes.getNode()) { if (node.getName().equals("localhost-"+domain.getName())) { return node; } } return null; }
for (int i : ids) { System.out.println(DASH); System.out.println("Domain name = " + d.getName() + " | ID = " + d.getID() + " | OSType = " + d.getOSType()); System.out.println("MaxMemory = " + d.getMaxMemory() + " | " + d.getMaxVcpus()); System.out.println("UUID = " + d.getUUIDString());
String nodeName = child.getName(); if (nodeName.equals("localhost-" + domain.getName())) { // can't delete localhost node final String msg = localStrings.getLocalString( "Node.localhost",
String nodeName = child.getName(); if (nodeName.equals("localhost-" + domain.getName())) { // can't delete localhost node final String msg = localStrings.getLocalString( "Node.localhost",
String domainName = domain.getName(); Cluster cluster = domain.getServerNamed(instanceName).getCluster();
if (hostName == null && nodeName.equals("localhost-" + domain.getName())) { hostName = "localhost";
if (hostName == null && nodeName.equals("localhost-" + domain.getName())) { hostName = "localhost";