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
}
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations