Example usage for java.net UnknownHostException getMessage

List of usage examples for java.net UnknownHostException getMessage

Introduction

In this page you can find the example usage for java.net UnknownHostException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.hawkular.component.pinger.Pinger.java

/**
 * Performs a test request against the given {@link PingDestination}.
 *
 * @param destination the destination to ping
 * @return a {@link Future}//from   w w  w. j  a v  a  2s. c om
 */
@Asynchronous
public Future<PingStatus> ping(final PingDestination destination) {
    Log.LOG.debugf("About to ping %s", destination.getUrl());
    HttpUriRequest request = RequestBuilder.create(destination.getMethod()).setUri(destination.getUrl())
            .build();

    try (CloseableHttpClient client = getHttpClient(destination.getUrl())) {
        long start = System.currentTimeMillis();
        HttpResponse httpResponse = client.execute(request);
        StatusLine statusLine = httpResponse.getStatusLine();
        EntityUtils.consumeQuietly(httpResponse.getEntity());
        long now = System.currentTimeMillis();

        final int code = statusLine.getStatusCode();
        final int duration = (int) (now - start);
        Traits traits = Traits.collect(httpResponse, now);
        PingStatus result = new PingStatus(destination, code, now, duration, traits);
        Log.LOG.debugf("Got status code %d from %s", code, destination.getUrl());
        return new AsyncResult<>(result);
    } catch (UnknownHostException e) {
        PingStatus result = PingStatus.error(destination, 404, System.currentTimeMillis());
        Log.LOG.debugf("Got UnknownHostException for %s", destination.getUrl());
        return new AsyncResult<>(result);
    } catch (IOException e) {
        Log.LOG.dCouldNotPingUrl(destination.getUrl(), e.getMessage());
        PingStatus result = PingStatus.error(destination, 500, System.currentTimeMillis());
        return new AsyncResult<>(result);
    }

}

From source file:de.nava.informa.utils.PersistChanGrpMgrTask.java

/**
 * handleChannelHeader -/*  ww  w  . j  ava 2 s. c  o m*/
 *
 * @param chan
 * @param info -
 */
private void handleChannelHeader(Channel chan, UpdateChannelInfo info) {
    if (!info.getFormatDetected()) { // If format has been detected then we've seen this Channel
        // already
        LOG.debug("Handling Channel Header. Format not yet detected.");
        try {
            builder.beginTransaction();
            builder.reload(chan);
            ChannelFormat format = FormatDetector.getFormat(chan.getLocation());
            chan.setFormat(format);
            info.setFormatDetected(true);
            chan.setLastUpdated(new Date());
            builder.endTransaction();
        } catch (UnknownHostException e) {
            // Normal situation when user is offline
            LOG.debug("Host not found: " + e.getMessage());
        } catch (Exception e) {
            info.increaseProblemsOccurred(e);
            String msg = "Exception in handleChannelHeader for : " + chan;
            LOG.error(msg + "\n     Continue....");
        } finally {
            // If there was an exception we still will be in transaction.
            if (builder.inTransaction())
                builder.resetTransaction();
        }
    }
}

From source file:org.squidy.nodes.Tracking.java

/**
 * /*from   w w w . j ava 2  s.c  o  m*/
 */
private void startMulticastServer() throws ProcessException {
    InetAddress multicastGroup;
    try {
        multicastGroup = InetAddress.getByName(multicastGroupAddress);
    } catch (UnknownHostException e) {
        throw new ProcessException(e.getMessage(), e);
    }

    server = new MulticastServer(multicastGroup, port);

    server.addMulticastListener(new MulticastAdapter() {

        /* (non-Javadoc)
         * @see org.squidy.manager.protocol.udp.UDPListener#parseData(byte[])
         */
        public void parseData(byte[] data) {
            // TODO [SF]: Do your parsing stuff here!!!
            ByteArrayInputStream bais = new ByteArrayInputStream(data);
            DataInputStream instream = new DataInputStream(bais);

            try {
                System.out.println("short: " + instream.readUnsignedShort() + " | "
                        + instream.readUnsignedShort() + " | " + (instream.readInt() & 0x7F));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            //               
            //            String s = new String(data);
            //            System.out.println(s);

            /*   
             *              Data is coded with a started MessageID = 7
                         lastFrameCounter = <FrameId>;         
                                 
                          if (<singleMarker == true>){
                                  
                             trackedBodies = <numTrackedSingleMarker>;
                             bodyId = 0;
                                  
                             //Read x,y,z and convert to mm
                             x = <x>*100; 
                             y = <y>*100;
                             z = <z>*100;
                                  
                             publish(new DataPosition3D(Tracking.class, bodyID, x, y, z, width,
                              height, depth, lastFrameCounter, trackedBodies));
                                      
                           // only publish single marker positions, not the ones belonging to a rigit body   
                          }
                          if (<rigitBody == true>){
                                  
                             trackedBodies = <numTrackedRigitBodies>;
                               bodyId = <rigitBodyId>;             
                             //Read x,y,z and convert to mm
                             x = <x>*100; 
                             y = <y>*100;
                             z = <z>*100;
                                     
                             //Read quatrions
                             qx = <qx>;
                             qy = <qy>;
                             qz = <qz>;
                             qw = <qw>;
                                     
                             //Transform to rotation matrix
                             //Spalte 1:
                           rxx = 2*(qx*qx + qw*qw)-1;
                           ryx = 2*(qx*qy + qz*qw);
                           rzx = 2*(qx*qz - qy*qw);
                           Spalte 2:
                           rxy = 2*(qx*qy - qz*qw);
                           ryy = 2*(qy*qy + qq*qw)-1;
                           rzy = 2*(qy*qz + qx*qw);
                           Spalte 3:
                           rxz = 2*(qx*qz + qy*qw);
                           ryz = 2*(qy*qz - qx*qw);
                           rzz = 2*(qz*qz + qw*qw)-1;
                                
                           //quadToMatrix: ?
                           //m[0] = 1-2*q[1]*q[1]-2*q[2]*q[2]; m[1] = 2*q[0]*q[1]-2*q[3]*q[2];   m[2] = 2*q[0]*q[2]+2*q[3]*q[1];
                             //m[3] = 2*q[0]*q[1]+2*q[3]*q[2];   m[4] = 1-2*q[0]*q[0]-2*q[2]*q[2]; m[5] = 2*q[1]*q[2]-2*q[3]*q[0];
                             //m[6] = 2*q[0]*q[2]-2*q[3]*q[1];   m[7] = 2*q[1]*q[2]+2*q[3]*q[0];   m[8] = 1-2*q[0]*q[0]-2*q[1]*q[1];
                                  
                             publish(new DataPosition6D(arTracking.getClass(), bodyID, x, y, z, width,
                           height, depth, rxx, ryx, rzx, rxy, ryy, rzy, rxz, ryz, rzz, lastFrameCounter,
                           trackedBodies));
                    
                                
                        }
                                
                                
            */

            //         
            //             ...
        }
    });
}

From source file:com.netflix.spinnaker.halyard.deploy.provider.v1.kubernetes.KubernetesOperationFactory.java

private KubernetesLoadBalancerDescription baseLoadBalancerDescription(String accountName,
        SpinnakerService service) {//  w  w w.j  av a  2s.  c o  m
    String address = service.getAddress();
    int port = service.getPort();
    KubernetesLoadBalancerDescription description = new KubernetesLoadBalancerDescription();

    String namespace = KubernetesProviderInterface.getNamespaceFromAddress(address);
    String name = KubernetesProviderInterface.getServiceFromAddress(address);
    Names parsedName = Names.parseName(name);
    description.setApp(parsedName.getApp());
    description.setStack(parsedName.getStack());
    description.setDetail(parsedName.getDetail());

    description.setName(name);
    description.setNamespace(namespace);
    description.setAccount(accountName);

    KubernetesNamedServicePort servicePort = new KubernetesNamedServicePort();
    servicePort.setPort(port);
    servicePort.setTargetPort(port);
    servicePort.setName("http");
    servicePort.setProtocol("TCP");

    if (service instanceof SpinnakerPublicService) {
        SpinnakerPublicService publicService = (SpinnakerPublicService) service;
        String publicAddress = publicService.getPublicAddress();
        InetAddress addr;
        try {
            addr = InetAddress.getByName(publicAddress);
        } catch (UnknownHostException e) {
            throw new HalException(new ProblemBuilder(Problem.Severity.FATAL,
                    "Failed to parse supplied public address: " + e.getMessage()).build());
        }

        if (!(addr.isAnyLocalAddress() || addr.isLoopbackAddress())) {
            description.setLoadBalancerIp(publicService.getPublicAddress());
            description.setServiceType("LoadBalancer");
        }
    }

    List<KubernetesNamedServicePort> servicePorts = new ArrayList<>();
    servicePorts.add(servicePort);
    description.setPorts(servicePorts);

    return description;
}

From source file:com.cloudera.flume.handlers.hdfs.CustomDfsSink.java

public CustomDfsSink(String path, OutputFormat format, Event event) {

    Preconditions.checkArgument(path != null);
    Preconditions.checkArgument(format != null);
    this.path = path;
    this.format = format;
    this.writer = null;
    this.localEvent = event;
    cal = Calendar.getInstance();
    cal.setTimeInMillis(localEvent.getTimestamp());
    this.conf = FlumeConfiguration.get();
    try {/*from  w w  w  .  j av  a 2s . co  m*/
        machineHostName = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        LOG.error("Error getting hostname for local machine: " + e.getMessage());
    }

}

From source file:com.mirth.connect.connectors.tcp.TcpMessageReceiver.java

public void doConnect() throws ConnectException {
    disposing.set(false);//from w w  w. j  ava  2  s  . com
    URI uri = endpoint.getEndpointURI().getUri();
    try {
        serverSocket = createSocket(uri);
        monitoringController.updateStatus(connector, connectorType, Event.INITIALIZED);
    } catch (UnknownHostException e) {
        logger.error(e.getClass().getName() + ": " + e.getMessage());
        throw new org.mule.providers.ConnectException(new Message("tcp", 1, uri), e, this);
    } catch (Exception e) {
        throw new org.mule.providers.ConnectException(new Message("tcp", 1, uri), e, this);
    }

    try {
        getWorkManager().scheduleWork(this, WorkManager.INDEFINITE, null, null);
    } catch (WorkException e) {
        throw new ConnectException(new Message(Messages.FAILED_TO_SCHEDULE_WORK), e, this);
    }
}

From source file:lumbermill.internal.geospatial.GeoIP.java

private Optional<CityResponse> locationOf(String ip) {
    try {/*from   w  ww .  j  a  v  a  2s .c om*/
        InetAddress ipAddress = InetAddress.getByName(ip);
        CityResponse response = reader.city(ipAddress);
        if (!hasLocations(response)) {
            return Optional.empty();
        }
        return Optional.of(response);
    } catch (UnknownHostException e) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("UnknownHostException: " + ip);
        }
    } catch (GeoIp2Exception e) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Unexpected GeoIp2Exception: " + e.getMessage());
        }
    } catch (IOException e) {
        LOGGER.warn("Unexpected IOException", e);
    }
    return Optional.empty();
}

From source file:org.hyperic.hq.agent.server.DefaultConnectionListener.java

public void setup(int connTimeout) throws AgentStartException {
    InetAddress addr;//from w ww .  j av a2  s.  c  o  m
    String listenIp;
    int listenPort;

    listenPort = this.getConfig().getListenPort();

    try {
        addr = this.getConfig().getListenIpAsAddr();
    } catch (UnknownHostException exc) {
        throw new AgentStartException("Failed to get IP for '" + this.getConfig().getListenIp() + "'");
    }

    try {
        this.listenSock = new ServerSocket(listenPort, 50, addr);
        this.listenSock.setSoTimeout(connTimeout);
    } catch (IOException exc) {
        throw new AgentStartException("Failed to setup listen socket: " + exc.getMessage());
    }
}

From source file:com.cloudera.flume.handlers.hdfs.CustomDfsSink.java

public CustomDfsSink(String path, OutputFormat format, Event event, String hiveTableName) {
    sb = new StringBuilder();

    Preconditions.checkArgument(path != null);
    Preconditions.checkArgument(format != null);
    this.path = path;
    this.localEvent = event;

    cal = Calendar.getInstance();
    cal.setTimeInMillis(localEvent.getTimestamp());
    this.format = format;
    this.writer = null;
    this.conf = FlumeConfiguration.get();
    this.hiveMarkerFolder = conf.getHiveDefaultMarkerFolder();

    if (StringUtils.isNotBlank(hiveTableName)) {
        this.hiveOutput = true;
        this.hiveTableName = hiveTableName;
        hup = new MarkerStore(hiveTableName, null, false);
    }//  w  w  w .jav a 2  s  . co m

    try {
        machineHostName = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        LOG.error("Error getting hostname for local machine: " + e.getMessage());
    }
}

From source file:org.openhab.io.transport.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl.java

private @Nullable InetAddress getInetAddress(ModbusIPSlaveEndpoint key) {
    try {//from   w  ww . j a  va 2s  . c  om
        return InetAddress.getByName(key.getAddress());
    } catch (UnknownHostException e) {
        logger.error("KeyedPooledModbusSlaveConnectionFactory: Unknown host: {}. Connection creation failed.",
                e.getMessage());
        return null;
    }
}