本文整理汇总了Java中org.apache.mina.util.AvailablePortFinder类的典型用法代码示例。如果您正苦于以下问题:Java AvailablePortFinder类的具体用法?Java AvailablePortFinder怎么用?Java AvailablePortFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AvailablePortFinder类属于org.apache.mina.util包,在下文中一共展示了AvailablePortFinder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLdapServer
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
private ApacheDS startLdapServer() throws Exception {
Preconditions.checkState(directoryService.isStarted());
Preconditions.checkState(!ldapServer.isStarted());
int port = AvailablePortFinder.getNextAvailable(1024);
ldapServer.setTransports(new TcpTransport(port));
ldapServer.setDirectoryService(directoryService);
// Setup SASL mechanisms
Map<String, MechanismHandler> mechanismHandlerMap = Maps.newHashMap();
mechanismHandlerMap.put(SupportedSaslMechanisms.PLAIN, new PlainMechanismHandler());
mechanismHandlerMap.put(SupportedSaslMechanisms.CRAM_MD5, new CramMd5MechanismHandler());
mechanismHandlerMap.put(SupportedSaslMechanisms.DIGEST_MD5, new DigestMd5MechanismHandler());
mechanismHandlerMap.put(SupportedSaslMechanisms.GSSAPI, new GssapiMechanismHandler());
ldapServer.setSaslMechanismHandlers(mechanismHandlerMap);
ldapServer.setSaslHost("localhost");
ldapServer.setSaslRealms(Collections.singletonList(realm));
// TODO ldapServer.setSaslPrincipal();
// The base DN containing users that can be SASL authenticated.
ldapServer.setSearchBaseDn(baseDn);
ldapServer.start();
return this;
}
示例2: setUp
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
/**
* Get's the initial context factory for the provider's ou=system context root.
*
* @throws Exception
* if there is a failure of any kind
*/
protected void setUp() throws Exception {
setStart(getStart() + 1);
setDirectoryService(new DefaultDirectoryService());
getDirectoryService().setShutdownHookEnabled(false);
setPort(AvailablePortFinder.getNextAvailable(1024));
setLdapServer(new LdapServer());
getLdapServer().setTransports(new TcpTransport(getPort()));
getLdapServer().setDirectoryService(getDirectoryService());
setupSaslMechanisms(getLdapServer());
getDirectoryService().setWorkingDirectory(
new File("target" + File.separator + "server-work"));
doDelete(getDirectoryService().getWorkingDirectory());
configureDirectoryService();
getDirectoryService().startup();
configureLdapServer();
// TODO shouldn't this be before calling configureLdapServer() ???
getLdapServer().addExtendedOperationHandler(new StartTlsHandler());
getLdapServer().addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());
getLdapServer().start();
setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
}
示例3: setUp
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
configuration = new MutableServerStartupConfiguration();
configuration.setWorkingDirectory(new File(workingDir));
cleanWorkingDir(configuration.getWorkingDirectory());
port = AvailablePortFinder.getNextAvailable(1024);
configuration.setLdapPort(port);
// configuration.setShutdownHookEnabled(false);
serverEnv = new Hashtable<String, Object>(configuration
.toJndiEnvironment());
initialAuth();
serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
ServerContextFactory.class.getName());
serverEnv.put(Context.PROVIDER_URL, "");
rootDSE = new InitialLdapContext(serverEnv, null);
}
示例4: startES
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
public final void startES(final Settings settings) throws Exception {
FileUtils.deleteDirectory(new File("data"));
Set<Integer> ports = null;
int offset = 0;
final int windowsSize = 12;
do {
ports = AvailablePortFinder.getAvailablePorts(AvailablePortFinder.MAX_PORT_NUMBER - offset - windowsSize,
AvailablePortFinder.MAX_PORT_NUMBER - offset);
offset += windowsSize;
} while (ports.size() < 7);
final Iterator<Integer> portIt = ports.iterator();
elasticsearchHttpPort1 = portIt.next();
elasticsearchHttpPort2 = portIt.next();
elasticsearchHttpPort3 = portIt.next();
elasticsearchNodePort1 = portIt.next();
elasticsearchNodePort2 = portIt.next();
elasticsearchNodePort3 = portIt.next();
esNode1 = NodeWithArmor(getDefaultSettingsBuilder(1, elasticsearchNodePort1, elasticsearchHttpPort1, true, true).put(
settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build());
esNode2 = NodeWithArmor(
getDefaultSettingsBuilder(2, elasticsearchNodePort2, elasticsearchHttpPort2, true, true).put(
settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build());
esNode3 = NodeWithArmor(
getDefaultSettingsBuilder(3, elasticsearchNodePort3, elasticsearchHttpPort3, true, false).put(
settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build());
esNode1.start();
esNode2.start();
esNode3.start();
waitForGreenClusterState(esNode1.client());
}
示例5: getServerPort
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
private int getServerPort(KdcConfiguration configuration) {
int port = configuration.getKdcCommunicationPort();
if (port == -1) {
port = AvailablePortFinder.getNextAvailable(START_PORT);
}
return port;
}
示例6: createTransport
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
private static Transport createTransport( CreateTransport transportBuilder, int startPort )
{
String protocol = transportBuilder.protocol();
int port = transportBuilder.port();
int nbThreads = transportBuilder.nbThreads();
int backlog = transportBuilder.backlog();
String address = transportBuilder.address();
if ( port == -1 )
{
port = AvailablePortFinder.getNextAvailable( startPort );
startPort = port + 1;
}
if ( protocol.equalsIgnoreCase( "TCP" ) )
{
Transport tcp = new TcpTransport( address, port, nbThreads, backlog );
return tcp;
}
else if ( protocol.equalsIgnoreCase( "UDP" ) )
{
UdpTransport udp = new UdpTransport( address, port );
return udp;
}
else
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_689, protocol ) );
}
}
示例7: setUp
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
protected void setUp() throws Exception
{
super.setUp();
port = AvailablePortFinder.getNextAvailable(12000);
}
示例8: findFreePort
import org.apache.mina.util.AvailablePortFinder; //导入依赖的package包/类
public int findFreePort()
{
return AvailablePortFinder.getNextAvailable(10000);
}