List of usage examples for io.netty.util.internal PlatformDependent isWindows
public static boolean isWindows()
From source file:org.onosproject.bgp.controller.impl.Controller.java
License:Apache License
/** * Starts the BGP controller./*w w w . j a va 2 s . c o m*/ */ public void start() { log.info("Started"); if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) { portNumber = BGP_PRIVILEGED_PORT; } else { portNumber = BGP_PORT_NUM; } this.init(); this.run(); }
From source file:org.opendaylight.controller.config.yang.bgp.rib.impl.BGPPeerAcceptorModule.java
License:Open Source License
@Override public void customValidation() { // check if unix root user if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot() && getBindingPort().getValue() < PRIVILEGED_PORTS) { throw new AccessControlException( "Unable to bind port " + getBindingPort().getValue() + " while running as non-root user."); }/*from ww w. j av a 2s .c o m*/ // Try to parse address try { getAddress(); } catch (final IllegalArgumentException e) { throw new JmxAttributeValidationException("Unable to resolve configured address", e, Lists.newArrayList(bindingAddressJmxAttribute, bindingPortJmxAttribute)); } }
From source file:org.opendaylight.controller.config.yang.bgp.rib.impl.BGPPeerAcceptorModuleTest.java
License:Open Source License
@Test public void testCreateBeanDefaultAddress() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException { try {/* ww w.ja va 2 s.com*/ final CommitStatus status = createRegistryInstance(Optional.<IpAddress>absent(), Optional.<Integer>absent(), true, true); assertBeanCount(1, FACTORY_NAME); assertStatus(status, 3, 0, 0); verify(dispatcher).createServer(any(BGPPeerRegistry.class), any(InetSocketAddress.class)); } catch (final ValidationException e) { if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) { Assert.assertTrue(e.getMessage().contains("Unable to bind port")); } else { fail(); } } }
From source file:org.opendaylight.controller.config.yang.bmp.impl.BmpMonitorImplModule.java
License:Open Source License
@Override public void customValidation() { JmxAttributeValidationException.checkNotNull(getBindingPort(), bindingPortJmxAttribute); // check if unix root user if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot() && getBindingPort().getValue() < PRIVILEGED_PORTS) { throw new AccessControlException( "Unable to bind port " + getBindingPort().getValue() + " while running as non-root user."); }//from ww w . j a v a 2 s . c o m }
From source file:org.opendaylight.protocol.bgp.peer.acceptor.BGPPeerAcceptorImpl.java
License:Open Source License
public BGPPeerAcceptorImpl(final BgpPeerAcceptorConfig config, final BGPPeerRegistry peerRegistry, final BGPDispatcher bgpDispatcher) { final PortNumber portNumber = config.getBindingPort(); final IpAddress bindingAddress = config.getBindingAddress(); LOG.debug("Instantiating BGP Peer Acceptor : {}/{}", bindingAddress, portNumber); if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot() && portNumber.getValue() < PRIVILEGED_PORTS) { throw new AccessControlException( "Unable to bind port " + portNumber.getValue() + " while running as non-root user."); }/*from w w w.java 2 s . com*/ this.futureChannel = bgpDispatcher.createServer(peerRegistry, getAddress(bindingAddress, portNumber)); // Validate future success this.futureChannel.addListener(future -> { Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", getAddress(bindingAddress, portNumber), future.cause()); final Channel channel = this.futureChannel.channel(); if (Epoll.isAvailable()) { BGPPeerAcceptorImpl.this.listenerRegistration = peerRegistry.registerPeerRegisterListener( new BGPPeerAcceptorImpl.PeerRegistryListenerImpl(channel.config())); } }); }