Search in sources :

Example 91 with UnknownHostException

use of java.net.UnknownHostException in project ACS by ACS-Community.

the class AlarmSearchHelper method search.

//
// -- PUBLIC METHODS ----------------------------------------------
//
public void search(Selection selection, int nbOfRows) throws LaserConnectionException, LaserException, LaserTimeOutException {
    searchFinished(false);
    String console_id = "";
    String host_name = "";
    try {
        console_id = UUIDGenerator.getInstance().getUUID().toString();
        host_name = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        throw new LaserException("unable to get a unique id for the console : " + e.getMessage());
    }
    String init_topic = getSearchRootTopic() + "." + console_id;
    long init_subscription;
    try {
        init_subscription = getSubscriber().subscribe(init_topic, getSearchListener(), null);
    } catch (Exception e) {
        throw new LaserException("unable to subscribe to topic " + init_topic + " : " + e.getMessage());
    }
    // activate the selection on the BT
    Integer[] category_ids = getCategoryIds(selection);
    String sql = buildSQLFilter(selection, nbOfRows);
    try {
        if (m_laser != null) {
            int[] cis = new int[category_ids.length];
            for (int i = 0; i < category_ids.length; i++) cis[i] = category_ids[i].intValue();
            m_laser.search(cis, sql, console_id);
        } else {
            throw new NullPointerException("AlarmSystem component is null");
        }
    } catch (Exception e) {
        throw new LaserException("unable to perform initial selection at host " + host_name + " : " + e.getMessage());
    }
    resetInitWaitTime();
    waitForInit();
    try {
        // stop init subscription
        getSubscriber().unSubscribe(init_subscription);
    } catch (Exception e) {
    // Intentionally left blank
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserSearchException(cern.laser.client.services.selection.LaserSearchException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserTimeOutException(cern.laser.client.LaserTimeOutException) LaserException(cern.laser.client.LaserException)

Example 92 with UnknownHostException

use of java.net.UnknownHostException in project intellij-community by JetBrains.

the class TaskManagerImpl method testConnection.

@Override
public boolean testConnection(final TaskRepository repository) {
    TestConnectionTask task = new TestConnectionTask("Test connection") {

        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setText("Connecting to " + repository.getUrl() + "...");
            indicator.setFraction(0);
            indicator.setIndeterminate(true);
            try {
                myConnection = repository.createCancellableConnection();
                if (myConnection != null) {
                    Future<Exception> future = ApplicationManager.getApplication().executeOnPooledThread(myConnection);
                    while (true) {
                        try {
                            myException = future.get(100, TimeUnit.MILLISECONDS);
                            return;
                        } catch (TimeoutException ignore) {
                            try {
                                indicator.checkCanceled();
                            } catch (ProcessCanceledException e) {
                                myException = e;
                                myConnection.cancel();
                                return;
                            }
                        } catch (Exception e) {
                            myException = e;
                            return;
                        }
                    }
                } else {
                    try {
                        repository.testConnection();
                    } catch (Exception e) {
                        LOG.info(e);
                        myException = e;
                    }
                }
            } catch (Exception e) {
                myException = e;
            }
        }
    };
    ProgressManager.getInstance().run(task);
    Exception e = task.myException;
    if (e == null) {
        myBadRepositories.remove(repository);
        Messages.showMessageDialog(myProject, "Connection is successful", "Connection", Messages.getInformationIcon());
    } else if (!(e instanceof ProcessCanceledException)) {
        String message = e.getMessage();
        if (e instanceof UnknownHostException) {
            message = "Unknown host: " + message;
        }
        if (message == null) {
            LOG.error(e);
            message = "Unknown error";
        }
        Messages.showErrorDialog(myProject, StringUtil.capitalize(message), "Error");
    }
    return e == null;
}
Also used : UnknownHostException(java.net.UnknownHostException) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) NotNull(org.jetbrains.annotations.NotNull) TimeoutException(java.util.concurrent.TimeoutException) XmlSerializationException(com.intellij.util.xmlb.XmlSerializationException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) SocketTimeoutException(java.net.SocketTimeoutException) UnknownHostException(java.net.UnknownHostException) TimeoutException(java.util.concurrent.TimeoutException) SocketTimeoutException(java.net.SocketTimeoutException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 93 with UnknownHostException

use of java.net.UnknownHostException in project intellij-community by JetBrains.

the class DependencyResolvingBuilder method build.

@Override
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
    final Exception error = context.getUserData(RESOLVE_ERROR_KEY);
    if (error != null) {
        final StringBuilder builder = new StringBuilder().append("Error resolving dependencies for ").append(chunk.getPresentableShortName());
        Throwable th = error;
        final Set<Throwable> processed = new HashSet<>();
        final Set<String> detailsMessage = new HashSet<>();
        while (th != null && processed.add(th)) {
            String details = th.getMessage();
            if (th instanceof UnknownHostException) {
                // hack for UnknownHostException
                details = "Unknown host: " + details;
            }
            if (details != null && detailsMessage.add(details)) {
                builder.append(":\n").append(details);
            }
            th = th.getCause();
        }
        final String msg = builder.toString();
        LOG.info(msg, error);
        context.processMessage(new CompilerMessage(NAME, BuildMessage.Kind.ERROR, msg));
        return ExitCode.ABORT;
    }
    return ExitCode.OK;
}
Also used : CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) THashSet(gnu.trove.THashSet) SmartHashSet(com.intellij.util.containers.SmartHashSet)

Example 94 with UnknownHostException

use of java.net.UnknownHostException in project CloudStack-archive by CloudStack-extras.

the class NetUtils method parseIpAddress.

private static InetAddress parseIpAddress(String address) {
    StringTokenizer st = new StringTokenizer(address, ".");
    byte[] bytes = new byte[4];
    if (st.countTokens() == 4) {
        try {
            for (int i = 0; i < 4; i++) {
                bytes[i] = (byte) Integer.parseInt(st.nextToken());
            }
            return InetAddress.getByAddress(address, bytes);
        } catch (NumberFormatException nfe) {
            return null;
        } catch (UnknownHostException uhe) {
            return null;
        }
    }
    return null;
}
Also used : StringTokenizer(java.util.StringTokenizer) UnknownHostException(java.net.UnknownHostException)

Example 95 with UnknownHostException

use of java.net.UnknownHostException in project CloudStack-archive by CloudStack-extras.

the class FakeDhcpSnooper method getIPAddr.

@Override
public InetAddress getIPAddr(String macAddr, String vmName) {
    String ipAddr = _ipAddresses.poll();
    if (ipAddr == null) {
        s_logger.warn("No ip addresses left in queue");
        return null;
    }
    try {
        InetAddress inetAddr = InetAddress.getByName(ipAddr);
        _macIpMap.put(macAddr.toLowerCase(), ipAddr);
        _vmIpMap.put(vmName, inetAddr);
        s_logger.info("Got ip address " + ipAddr + " for vm " + vmName + " mac=" + macAddr.toLowerCase());
        return inetAddr;
    } catch (UnknownHostException e) {
        s_logger.warn("Failed to get InetAddress for " + ipAddr);
        return null;
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) InetAddress(java.net.InetAddress)

Aggregations

UnknownHostException (java.net.UnknownHostException)1736 InetAddress (java.net.InetAddress)726 IOException (java.io.IOException)446 InetSocketAddress (java.net.InetSocketAddress)150 ArrayList (java.util.ArrayList)142 SocketException (java.net.SocketException)135 Test (org.junit.Test)122 Socket (java.net.Socket)93 URL (java.net.URL)77 SocketTimeoutException (java.net.SocketTimeoutException)71 HashMap (java.util.HashMap)71 File (java.io.File)67 MalformedURLException (java.net.MalformedURLException)65 NetworkInterface (java.net.NetworkInterface)58 URI (java.net.URI)55 ConnectException (java.net.ConnectException)54 InputStream (java.io.InputStream)53 Inet4Address (java.net.Inet4Address)52 Inet6Address (java.net.Inet6Address)52 List (java.util.List)51