03.01.2015 Views

a multi-objective bisexual reproduction genetic algorithm for ...

a multi-objective bisexual reproduction genetic algorithm for ...

a multi-objective bisexual reproduction genetic algorithm for ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

123<br />

public String getTheBestHost(){<br />

GridInfoSearch gridInfoSearch = new GridInfoSearch();<br />

String filter = "(&(Mds-Device-Group-name=processors)(Mds-Cpu-Free-1minX100>=0))";<br />

gridInfoSearch.search(filter);<br />

ob.displayHost();<br />

System.out.println("the best:"+ob.getBestHost());<br />

return ob.getBestHost();<br />

}<br />

//Search the ldap server <strong>for</strong> the filter specified in the main function<br />

private void search(String filter) {<br />

Hashtable env = new Hashtable();<br />

String url = "ldap://" + hostname + ":" + port;<br />

env.put("java.naming.ldap.version", String.valueOf(ldapVersion));<br />

env.put(Context.INITIAL_CONTEXT_FACTORY, DEFAULT_CTX);<br />

env.put(Context.PROVIDER_URL, url);<br />

if (bindDN != null) {<br />

env.put(Context.SECURITY_PRINCIPAL, bindDN);<br />

}<br />

//use GSI authentication from grid-proxy-init certificate<br />

saslMech = GSIMechanism.NAME;<br />

env.put("javax.security.sasl.client.pkgs",<br />

"org.globus.mds.gsi.jndi");<br />

env.put(Context.SECURITY_AUTHENTICATION, saslMech);<br />

env.put("javax.security.sasl.qop", qop);<br />

LdapContext ctx = null;<br />

//create a new ldap context to hold per<strong>for</strong>m search on filter<br />

try {<br />

ctx = new InitialLdapContext(env, null);<br />

SearchControls constraints = new SearchControls();<br />

constraints.setSearchScope(scope);<br />

constraints.setCountLimit(sizeLimit);<br />

constraints.setTimeLimit(timeLimit);<br />

//store the results of the search in the results variable<br />

NamingEnumeration results = ctx.search(baseDN, filter, constraints);<br />

//displayResults(results);<br />

getAvailableHosts(results);//the results will be stored in ob<br />

} catch (Exception e) {<br />

System.err.println("Failed to search: " + e.getMessage());<br />

} finally {<br />

if (ctx != null) {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!