This is an automated email from the ASF dual-hosted git repository.
yasithdev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/master by this push:
new bb09012c61 Remove dead code from airavata-api (#628)
bb09012c61 is described below
commit bb09012c61ffc686a9f7ac851ed33370e82e57c1
Author: Yasith Jayawardana <[email protected]>
AuthorDate: Sun Jun 7 16:46:56 2026 -0400
Remove dead code from airavata-api (#628)
* chore: remove dead instrumentation classes
StatCounter/CountWriterTask/LatencyWriterTask
These three messaging/util classes reference only each other and have no
external callers; StatCounter also spun up two Timer threads writing to
hardcoded /tmp paths. Remove the whole unused cluster.
* chore: delete unused SwingUtil AWT/Swing helper
A desktop GUI helper has no place in a headless gRPC/REST server and has
zero references.
* chore: remove unwired MonitoringServer and its
ServiceRegistry/ServiceStatus
MonitoringServer stands up a com.sun HttpServer that is never constructed or
registered; metrics are served by Spring Actuator. The three classes
reference only each other. GaugeMonitor/CountMonitor are untouched.
* chore: delete unused LocalEventPublisher
An unwired Guava EventBus wrapper with no Spring stereotype and no callers;
the real publishers are RabbitMQ-backed.
* chore: remove dead SSH-adaptor cluster from compute-service
SshAgentAdaptor, StorageResourceAdaptorImpl, SshAdaptorParams and
AdaptorParams form a closed, unreachable cluster; the live factory wires
SSHJ adaptors exclusively. The StorageResourceAdaptor interface,
StandardOutReader and SSHConnectionService are kept.
* chore: delete unused appcatalog proto-builder helpers from compute-service
AppInterfaceUtil and AppDeploymentUtil build research-service appcatalog
protos and have no callers.
---
.../airavata/compute/util/AdaptorParams.java | 43 ---
.../airavata/compute/util/AppDeploymentUtil.java | 43 ---
.../airavata/compute/util/AppInterfaceUtil.java | 70 ----
.../airavata/compute/util/SshAdaptorParams.java | 133 --------
.../airavata/compute/util/SshAgentAdaptor.java | 336 -------------------
.../compute/util/StorageResourceAdaptorImpl.java | 86 -----
.../messaging/service/LocalEventPublisher.java | 45 ---
.../airavata/messaging/util/CountWriterTask.java | 52 ---
.../airavata/messaging/util/LatencyWriterTask.java | 53 ---
.../airavata/messaging/util/StatCounter.java | 99 ------
.../apache/airavata/server/MonitoringServer.java | 191 -----------
.../apache/airavata/server/ServiceRegistry.java | 152 ---------
.../org/apache/airavata/server/ServiceStatus.java | 62 ----
.../java/org/apache/airavata/util/SwingUtil.java | 356 ---------------------
14 files changed, 1721 deletions(-)
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AdaptorParams.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AdaptorParams.java
deleted file mode 100644
index 83e084408b..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AdaptorParams.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * This class provides methods to serialize and deserialize its instances to
and from JSON files using Jackson's ObjectMapper
- *
- * @author dimuthu
- * @since 1.0.0-SNAPSHOT
- */
-public class AdaptorParams {
-
- public Object loadFromFile(File file) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(file, this.getClass());
- }
-
- public void writeToFile(File file) throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(file, this);
- }
-}
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppDeploymentUtil.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppDeploymentUtil.java
deleted file mode 100644
index 05cf3e0dcb..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppDeploymentUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import
org.apache.airavata.model.appcatalog.appdeployment.proto.ApplicationDeploymentDescription;
-import org.apache.airavata.model.appcatalog.appdeployment.proto.SetEnvPaths;
-
-public class AppDeploymentUtil {
- public static ApplicationDeploymentDescription createAppDeployment(
- String moduleId,
- String computeHost,
- String executablePath,
- String appDepDescription,
- String moduleLoadCmd) {
- return ApplicationDeploymentDescription.newBuilder()
- .setAppModuleId(moduleId)
- .setComputeHostId(computeHost)
- .setExecutablePath(executablePath)
- .setAppDeploymentDescription(appDepDescription)
- .build();
- }
-
- public static SetEnvPaths createEnvPath(String name, String val) {
- return SetEnvPaths.newBuilder().setName(name).setValue(val).build();
- }
-}
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppInterfaceUtil.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppInterfaceUtil.java
deleted file mode 100644
index dba4dacf06..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/AppInterfaceUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import java.util.List;
-import
org.apache.airavata.model.appcatalog.appinterface.proto.ApplicationInterfaceDescription;
-import org.apache.airavata.model.application.io.proto.DataType;
-import org.apache.airavata.model.application.io.proto.InputDataObjectType;
-import org.apache.airavata.model.application.io.proto.OutputDataObjectType;
-
-public class AppInterfaceUtil {
- public static ApplicationInterfaceDescription createAppInterface(
- String applicationName,
- List<String> appModules,
- List<InputDataObjectType> appInputs,
- List<OutputDataObjectType> appOutputs) {
- return ApplicationInterfaceDescription.newBuilder()
- .setApplicationName(applicationName)
- .addAllApplicationModules(appModules)
- .addAllApplicationInputs(appInputs)
- .addAllApplicationOutputs(appOutputs)
- .build();
- }
-
- public static InputDataObjectType createApplicationInput(
- String name,
- String value,
- DataType type,
- String applicationArgument,
- int order,
- boolean standardInput,
- String userFriendlyDesc,
- String metadata) {
- return InputDataObjectType.newBuilder()
- .setName(name)
- .setValue(value)
- .setType(type)
- .setMetaData(metadata)
- .setApplicationArgument(applicationArgument)
- .setInputOrder(order)
- .setUserFriendlyDescription(userFriendlyDesc)
- .setStandardInput(standardInput)
- .build();
- }
-
- public static OutputDataObjectType createApplicationOutput(String name,
String value, DataType type) {
- return OutputDataObjectType.newBuilder()
- .setName(name)
- .setValue(value)
- .setType(type)
- .build();
- }
-}
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAdaptorParams.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAdaptorParams.java
deleted file mode 100644
index 3edf45f7ec..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAdaptorParams.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import java.io.*;
-
-/**
- * TODO: Class level comments please
- *
- * @author dimuthu
- * @since 1.0.0-SNAPSHOT
- */
-public class SshAdaptorParams extends AdaptorParams implements Serializable {
-
- private int port = 22;
- private String hostName;
- private String userName;
-
- private String password;
-
- private byte[] publicKey;
- private byte[] privateKey;
- private String passphrase;
-
- private String knownHostsFilePath;
- private boolean strictHostKeyChecking;
-
- public int getPort() {
- return port;
- }
-
- public SshAdaptorParams setPort(int port) {
- this.port = port;
- return this;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public SshAdaptorParams setHostName(String hostName) {
- this.hostName = hostName;
- return this;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public SshAdaptorParams setUserName(String userName) {
- this.userName = userName;
- return this;
- }
-
- public String getPassword() {
- return password;
- }
-
- public SshAdaptorParams setPassword(String password) {
- this.password = password;
- return this;
- }
-
- public byte[] getPublicKey() {
- return publicKey;
- }
-
- public SshAdaptorParams setPublicKey(byte[] publicKey) {
- this.publicKey = publicKey;
- return this;
- }
-
- public byte[] getPrivateKey() {
- return privateKey;
- }
-
- public SshAdaptorParams setPrivateKey(byte[] privateKey) {
- this.privateKey = privateKey;
- return this;
- }
-
- public String getPassphrase() {
- return passphrase;
- }
-
- public SshAdaptorParams setPassphrase(String passphrase) {
- this.passphrase = passphrase;
- return this;
- }
-
- public String getKnownHostsFilePath() {
- return knownHostsFilePath;
- }
-
- public SshAdaptorParams setKnownHostsFilePath(String knownHostsFilePath) {
- this.knownHostsFilePath = knownHostsFilePath;
- return this;
- }
-
- public boolean isStrictHostKeyChecking() {
- return strictHostKeyChecking;
- }
-
- public SshAdaptorParams setStrictHostKeyChecking(boolean
strictHostKeyChecking) {
- this.strictHostKeyChecking = strictHostKeyChecking;
- return this;
- }
-
- public static void main(String args[]) throws IOException {
- SshAdaptorParams params = new SshAdaptorParams();
- params.setUserName("dimuthu");
- params.setPassword("upe");
- params.setHostName("localhost");
- params.writeToFile(new File("/tmp/ssh-param.json"));
- }
-}
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAgentAdaptor.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAgentAdaptor.java
deleted file mode 100644
index 71e65376bd..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/SshAgentAdaptor.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import java.io.*;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import org.apache.airavata.interfaces.AgentAdaptor;
-import org.apache.airavata.interfaces.AgentException;
-import org.apache.airavata.interfaces.CommandOutput;
-import org.apache.airavata.interfaces.FileMetadata;
-import org.apache.airavata.interfaces.SSHConnectionService;
-import org.apache.airavata.interfaces.SSHConnectionService.*;
-import org.apache.airavata.model.appcatalog.computeresource.proto.*;
-import
org.apache.airavata.model.appcatalog.storageresource.proto.StorageDirectoryInfo;
-import
org.apache.airavata.model.appcatalog.storageresource.proto.StorageVolumeInfo;
-import org.apache.airavata.model.credential.store.proto.SSHCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SSH agent adaptor using SSHConnectionService.
- *
- * @author dimuthu
- * @since 1.0.0-SNAPSHOT
- */
-public class SshAgentAdaptor implements AgentAdaptor {
-
- private static final Logger logger =
LoggerFactory.getLogger(SshAgentAdaptor.class);
-
- private SSHConnectionService sshConnectionService;
- private SSHConnection sshConnection;
- private String host;
- private int port;
- private String userName;
-
- public SshAgentAdaptor() {}
-
- public SshAgentAdaptor(SSHConnectionService sshConnectionService) {
- this.sshConnectionService = sshConnectionService;
- }
-
- public void setSshConnectionService(SSHConnectionService
sshConnectionService) {
- this.sshConnectionService = sshConnectionService;
- }
-
- public void init(AdaptorParams adaptorParams) throws AgentException {
-
- if (adaptorParams instanceof SshAdaptorParams) {
- SshAdaptorParams params =
SshAdaptorParams.class.cast(adaptorParams);
- try {
- this.host = params.getHostName();
- this.port = params.getPort();
- this.userName = params.getUserName();
-
- if (params.getPassword() != null) {
- sshConnection = sshConnectionService.connectWithPassword(
- params.getHostName(), params.getPort(),
params.getUserName(), params.getPassword());
- } else {
- sshConnection = sshConnectionService.connectSimple(
- params.getHostName(),
- params.getPort(),
- params.getUserName(),
- new String(params.getPublicKey()),
- new String(params.getPrivateKey()),
- params.getPassphrase());
- }
-
- } catch (IOException e) {
- throw new AgentException("Could not create ssh session for
host " + params.getHostName(), e);
- }
- } else {
- throw new AgentException(
- "Unknown parameter type to ssh initialize agent adaptor.
Required SshAdaptorParams type");
- }
- }
-
- @Override
- public void init(String computeResourceId, String gatewayId, String
userId, String token) throws AgentException {
- try {
- ComputeResourceDescription computeResourceDescription =
-
AgentUtils.getRegistryServiceClient().getComputeResource(computeResourceId);
-
- logger.info("Fetching credentials for cred store token " + token);
-
- SSHCredential sshCredential =
AgentUtils.getCredentialClient().getSSHCredential(token, gatewayId);
- if (sshCredential == null) {
- throw new AgentException("Null credential for token " + token);
- }
- logger.info("Description for token : " + token + " : " +
sshCredential.getDescription());
-
- SshAdaptorParams adaptorParams = new SshAdaptorParams();
-
adaptorParams.setHostName(computeResourceDescription.getHostName());
- adaptorParams.setUserName(userId);
- adaptorParams.setPassphrase(sshCredential.getPassphrase());
-
adaptorParams.setPrivateKey(sshCredential.getPrivateKey().getBytes());
-
adaptorParams.setPublicKey(sshCredential.getPublicKey().getBytes());
- adaptorParams.setStrictHostKeyChecking(false);
- init(adaptorParams);
-
- } catch (Exception e) {
- logger.error(
- "Error while initializing ssh agent for compute resource "
+ computeResourceId + " to token "
- + token,
- e);
- throw new AgentException(
- "Error while initializing ssh agent for compute resource "
+ computeResourceId + " to token "
- + token,
- e);
- }
- }
-
- @Override
- public void destroy() {}
-
- public CommandOutput executeCommand(String command, String
workingDirectory) throws AgentException {
- StandardOutReader commandOutput = new StandardOutReader();
- try (SSHSession session = sshConnection.startSession()) {
- String fullCommand = (workingDirectory != null ? "cd " +
workingDirectory + "; " : "") + command;
- SSHCommandResult cmd = session.exec(fullCommand);
-
- commandOutput.readStdOutFromStream(cmd.getInputStream());
- commandOutput.readStdErrFromStream(cmd.getErrorStream());
- cmd.join(30, TimeUnit.SECONDS);
- commandOutput.setExitCode(cmd.getExitStatus());
- return commandOutput;
- } catch (IOException e) {
- logger.error("Failed to execute command " + command, e);
- throw new AgentException("Failed to execute command " + command,
e);
- }
- }
-
- public void createDirectory(String path) throws AgentException {
- createDirectory(path, false);
- }
-
- @Override
- public void createDirectory(String path, boolean recursive) throws
AgentException {
- String command = (recursive ? "mkdir -p " : "mkdir ") + path;
- try (SSHSession session = sshConnection.startSession()) {
- SSHCommandResult cmd = session.exec(command);
- StandardOutReader stdOutReader = new StandardOutReader();
-
- stdOutReader.readStdOutFromStream(cmd.getInputStream());
- stdOutReader.readStdErrFromStream(cmd.getErrorStream());
- cmd.join(30, TimeUnit.SECONDS);
-
- if (stdOutReader.getStdError() != null &&
stdOutReader.getStdError().contains("mkdir:")) {
- throw new AgentException(stdOutReader.getStdError());
- }
- } catch (IOException e) {
- logger.error(
- "Unable to retrieve command output. Command - " + command
+ " on server - " + host + ":" + port
- + " connecting user name - " + userName,
- e);
- throw new AgentException(e);
- }
- }
-
- @Override
- public void deleteDirectory(String path) throws AgentException {
- if (path == null || path.trim().isEmpty()) {
- throw new AgentException("Directory path cannot be null or empty");
- }
- String escapedPath = path.replace("'", "'\"'\"'");
- String command = "rm -rf '" + escapedPath + "'";
- try (SSHSession session = sshConnection.startSession()) {
- SSHCommandResult cmd = session.exec(command);
- StandardOutReader stdOutReader = new StandardOutReader();
-
- stdOutReader.readStdOutFromStream(cmd.getInputStream());
- stdOutReader.readStdErrFromStream(cmd.getErrorStream());
- cmd.join(30, TimeUnit.SECONDS);
-
- if (stdOutReader.getStdError() != null &&
stdOutReader.getStdError().contains("rm:")) {
- throw new AgentException(stdOutReader.getStdError());
- }
- } catch (IOException e) {
- logger.error(
- "Unable to retrieve command output. Command - {} on server
- {}:{} connecting user name - {}",
- command,
- host,
- port,
- userName,
- e);
- throw new AgentException(e);
- }
- }
-
- public void uploadFile(String localFile, String remoteFile) throws
AgentException {
- try {
- SCPSession scp = sshConnection.newSCPFileTransfer();
- scp.upload(localFile, remoteFile);
- } catch (IOException e) {
- logger.error("Failed to transfer file from " + localFile + " to
remote location " + remoteFile, e);
- throw new AgentException(
- "Failed to transfer file from " + localFile + " to remote
location " + remoteFile, e);
- }
- }
-
- @Override
- public void uploadFile(InputStream localInStream, FileMetadata metadata,
String remoteFile) throws AgentException {
- throw new AgentException("Operation not implemented");
- }
-
- public void downloadFile(String remoteFile, String localFile) throws
AgentException {
- try {
- SCPSession scp = sshConnection.newSCPFileTransfer();
- scp.download(remoteFile, localFile);
- } catch (IOException e) {
- logger.error("Failed to transfer remote file from " + remoteFile +
" to location " + localFile, e);
- throw new AgentException(
- "Failed to transfer remote file from " + remoteFile + " to
location " + localFile, e);
- }
- }
-
- @Override
- public void downloadFile(String remoteFile, OutputStream localOutStream,
FileMetadata metadata)
- throws AgentException {
- throw new AgentException("Operation not implemented");
- }
-
- @Override
- public List<String> listDirectory(String path) throws AgentException {
- String command = "ls " + path;
- try (SSHSession session = sshConnection.startSession()) {
- SSHCommandResult cmd = session.exec(command);
- StandardOutReader stdOutReader = new StandardOutReader();
-
- stdOutReader.readStdOutFromStream(cmd.getInputStream());
- stdOutReader.readStdErrFromStream(cmd.getErrorStream());
- cmd.join(30, TimeUnit.SECONDS);
-
- if (stdOutReader.getStdError() != null &&
stdOutReader.getStdError().contains("ls:")) {
- throw new AgentException(stdOutReader.getStdError());
- }
- return Arrays.asList(stdOutReader.getStdOut().split("\n"));
-
- } catch (IOException e) {
- logger.error(
- "Unable to retrieve command output. Command - " + command
+ " on server - " + host + ":" + port
- + " connecting user name - " + userName,
- e);
- throw new AgentException(
- "Unable to retrieve command output. Command - " + command
+ " on server - " + host + ":" + port
- + " connecting user name - " + userName,
- e);
- }
- }
-
- @Override
- public Boolean doesFileExist(String filePath) throws AgentException {
- String command = "ls " + filePath;
- try (SSHSession session = sshConnection.startSession()) {
- SSHCommandResult cmd = session.exec(command);
- StandardOutReader stdOutReader = new StandardOutReader();
-
- stdOutReader.readStdOutFromStream(cmd.getInputStream());
- stdOutReader.readStdErrFromStream(cmd.getErrorStream());
- cmd.join(30, TimeUnit.SECONDS);
-
- if (stdOutReader.getStdError() != null &&
stdOutReader.getStdError().contains("ls:")) {
- logger.info("Invalid file path " + filePath + ". stderr : " +
stdOutReader.getStdError());
- return false;
- } else {
- String[] potentialFiles = stdOutReader.getStdOut().split("\n");
- if (potentialFiles.length > 1) {
- logger.info("More than one file matching to given path " +
filePath);
- return false;
- } else if (potentialFiles.length == 0) {
- logger.info("No file found for given path " + filePath);
- return false;
- } else {
- if (potentialFiles[0].trim().equals(filePath)) {
- return true;
- } else {
- logger.info("Returned file name " +
potentialFiles[0].trim()
- + " does not match with given name " +
filePath);
- return false;
- }
- }
- }
- } catch (IOException e) {
- logger.error(
- "Unable to retrieve command output. Command - " + command
+ " on server - " + host + ":" + port
- + " connecting user name - " + userName,
- e);
- throw new AgentException(
- "Unable to retrieve command output. Command - " + command
+ " on server - " + host + ":" + port
- + " connecting user name - " + userName,
- e);
- }
- }
-
- @Override
- public List<String> getFileNameFromExtension(String fileName, String
parentPath) throws AgentException {
- throw new AgentException("Operation not implemented");
- }
-
- @Override
- public FileMetadata getFileMetadata(String remoteFile) throws
AgentException {
- throw new AgentException("Operation not implemented");
- }
-
- @Deprecated(forRemoval = true)
- @Override
- public StorageVolumeInfo getStorageVolumeInfo(String location) {
- throw new UnsupportedOperationException(
- "Operation not supported by SshAgentAdaptor. Use
SSHJAgentAdaptor instead.");
- }
-
- @Deprecated(forRemoval = true)
- @Override
- public StorageDirectoryInfo getStorageDirectoryInfo(String location)
throws AgentException {
- throw new UnsupportedOperationException(
- "Operation not supported by SshAgentAdaptor. Use
SSHJAgentAdaptor instead.");
- }
-}
diff --git
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/StorageResourceAdaptorImpl.java
b/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/StorageResourceAdaptorImpl.java
deleted file mode 100644
index 03d22d8744..0000000000
---
a/airavata-api/compute-service/src/main/java/org/apache/airavata/compute/util/StorageResourceAdaptorImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.compute.util;
-
-import org.apache.airavata.interfaces.AgentException;
-import org.apache.airavata.interfaces.CommandOutput;
-import org.apache.airavata.interfaces.StorageResourceAdaptor;
-import
org.apache.airavata.model.appcatalog.storageresource.proto.StorageResourceDescription;
-import org.apache.airavata.model.credential.store.proto.SSHCredential;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StorageResourceAdaptorImpl extends SshAgentAdaptor implements
StorageResourceAdaptor {
-
- private static final Logger logger =
LoggerFactory.getLogger(StorageResourceAdaptorImpl.class);
-
- @Override
- public void init(String storageResourceId, String gatewayId, String
loginUser, String token) throws AgentException {
-
- try {
- logger.info("Initializing Storage Resource Adaptor for storage
resource : " + storageResourceId
- + ", gateway : " + gatewayId + ", user " + loginUser + ",
token : " + token);
- StorageResourceDescription storageResource =
-
AgentUtils.getRegistryServiceClient().getStorageResource(storageResourceId);
-
- logger.info("Fetching credentials for cred store token " + token);
-
- SSHCredential sshCredential =
AgentUtils.getCredentialClient().getSSHCredential(token, gatewayId);
- if (sshCredential == null) {
- throw new AgentException("Null credential for token " + token);
- }
- logger.info("Description for token : " + token + " : " +
sshCredential.getDescription());
-
- SshAdaptorParams adaptorParams = new SshAdaptorParams();
- adaptorParams.setHostName(storageResource.getHostName());
- adaptorParams.setUserName(loginUser);
- adaptorParams.setPassphrase(sshCredential.getPassphrase());
-
adaptorParams.setPrivateKey(sshCredential.getPrivateKey().getBytes());
-
adaptorParams.setPublicKey(sshCredential.getPublicKey().getBytes());
- adaptorParams.setStrictHostKeyChecking(false);
- init(adaptorParams);
-
- } catch (Exception e) {
- logger.error(
- "Error while initializing ssh agent for storage resource "
+ storageResourceId + " to token "
- + token,
- e);
- throw new AgentException(
- "Error while initializing ssh agent for storage resource "
+ storageResourceId + " to token "
- + token,
- e);
- }
- }
-
- @Override
- public void uploadFile(String localFile, String remoteFile) throws
AgentException {
- super.uploadFile(localFile, remoteFile);
- }
-
- @Override
- public void downloadFile(String remoteFile, String localFile) throws
AgentException {
- super.downloadFile(remoteFile, localFile);
- }
-
- @Override
- public CommandOutput executeCommand(String command, String
workingDirectory) throws AgentException {
- return super.executeCommand(command, workingDirectory);
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/messaging/service/LocalEventPublisher.java
b/airavata-api/src/main/java/org/apache/airavata/messaging/service/LocalEventPublisher.java
deleted file mode 100644
index 4e93838a31..0000000000
---
a/airavata-api/src/main/java/org/apache/airavata/messaging/service/LocalEventPublisher.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.messaging.service;
-
-import com.google.common.eventbus.EventBus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LocalEventPublisher {
- private static final Logger logger =
LoggerFactory.getLogger(LocalEventPublisher.class);
- private EventBus eventBus;
-
- public LocalEventPublisher(EventBus eventBus) {
- this.eventBus = eventBus;
- }
-
- public void registerListener(Object listener) {
- eventBus.register(listener);
- }
-
- public void unregisterListener(Object listener) {
- eventBus.unregister(listener);
- }
-
- public void publish(Object o) {
- eventBus.post(o);
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/CountWriterTask.java
b/airavata-api/src/main/java/org/apache/airavata/messaging/util/CountWriterTask.java
deleted file mode 100644
index c47233ffcf..0000000000
---
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/CountWriterTask.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.messaging.util;
-
-import java.io.*;
-import java.util.List;
-import java.util.TimerTask;
-
-public class CountWriterTask extends TimerTask {
-
- private File file;
- private FileOutputStream fos;
- private BufferedWriter bw;
-
- public void setFile(File file) {
- this.file = file;
- }
-
- @Override
- public void run() {
- try {
- StatCounter statCounter = StatCounter.getInstance();
- List<Long> contPer10S = statCounter.getMessageContPer10S();
- fos = new FileOutputStream(file, false);
- bw = new BufferedWriter(new OutputStreamWriter(fos));
- for (int i = 0; i < contPer10S.size(); i++) {
- bw.write(String.valueOf(i + 1) + " :" +
String.valueOf(contPer10S.get(i)));
- bw.newLine();
- }
- bw.flush();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/LatencyWriterTask.java
b/airavata-api/src/main/java/org/apache/airavata/messaging/util/LatencyWriterTask.java
deleted file mode 100644
index 49c05fa625..0000000000
---
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/LatencyWriterTask.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.messaging.util;
-
-import java.io.*;
-import java.util.Map;
-import java.util.TimerTask;
-
-public class LatencyWriterTask extends TimerTask {
-
- private File file;
- private FileOutputStream fos;
- private BufferedWriter bw;
-
- public void setFile(File file) {
- this.file = file;
- }
-
- @Override
- public void run() {
- try {
- System.out.println("########### Latency Write Task ############");
- StatCounter statCounter = StatCounter.getInstance();
- Map<String, Long> messageTimeStamp =
statCounter.getMessageTimeStamp();
- fos = new FileOutputStream(file, false);
- bw = new BufferedWriter(new OutputStreamWriter(fos));
- for (String msgId : messageTimeStamp.keySet()) {
- bw.write(msgId + " :" +
String.valueOf(messageTimeStamp.get(msgId)));
- bw.newLine();
- }
- bw.flush();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/StatCounter.java
b/airavata-api/src/main/java/org/apache/airavata/messaging/util/StatCounter.java
deleted file mode 100644
index a3afa4a03f..0000000000
---
a/airavata-api/src/main/java/org/apache/airavata/messaging/util/StatCounter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.messaging.util;
-
-import java.io.*;
-import java.util.*;
-import org.apache.airavata.model.messaging.event.proto.Message;
-
-public class StatCounter {
- private static StatCounter ourInstance = new StatCounter();
- private long msgCount;
- private long period = 10 * 1000;
- private long msgCountForPeriod;
-
- private long bucketStartTime = 0;
- private File file1;
- private File file2;
-
- private List<Long> messageContPer10S = new ArrayList<Long>();
- private Map<String, Long> messageTimeStamp = new HashMap<String, Long>();
-
- public static StatCounter getInstance() {
- return ourInstance;
- }
-
- public long getMsgCount() {
- return msgCount;
- }
-
- public void setMsgCount(long msgCount) {
- this.msgCount = msgCount;
- }
-
- public List<Long> getMessageContPer10S() {
- return messageContPer10S;
- }
-
- public void setMessageContPer10S(List<Long> messageContPer10S) {
- this.messageContPer10S = messageContPer10S;
- }
-
- private StatCounter() {
- file1 = new File("/tmp/results");
- file2 = new File("/tmp/latency");
- Timer counterTimer = new Timer();
- Timer latencyTimer = new Timer();
- CountWriterTask writerTask = new CountWriterTask();
- writerTask.setFile(file1);
- LatencyWriterTask latencyWriterTask = new LatencyWriterTask();
- latencyWriterTask.setFile(file2);
- counterTimer.scheduleAtFixedRate(writerTask, 0, 60 * 1000);
- latencyTimer.scheduleAtFixedRate(latencyWriterTask, 0, 60 * 1000);
- }
-
- public void add(Message message) {
- messageTimeStamp.put(message.getMessageId(),
System.currentTimeMillis());
- if (System.currentTimeMillis() - bucketStartTime < period) {
- msgCountForPeriod++;
- } else {
- messageContPer10S.add(msgCountForPeriod);
- bucketStartTime = System.currentTimeMillis();
- msgCountForPeriod = 1;
- }
- msgCount++;
- }
-
- public long getMsgCountForPeriod() {
- return msgCountForPeriod;
- }
-
- public void setMsgCountForPeriod(long msgCountForPeriod) {
- this.msgCountForPeriod = msgCountForPeriod;
- }
-
- public Map<String, Long> getMessageTimeStamp() {
- return messageTimeStamp;
- }
-
- public void setMessageTimeStamp(Map<String, Long> messageTimeStamp) {
- this.messageTimeStamp = messageTimeStamp;
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/server/MonitoringServer.java
b/airavata-api/src/main/java/org/apache/airavata/server/MonitoringServer.java
deleted file mode 100644
index b835919655..0000000000
---
a/airavata-api/src/main/java/org/apache/airavata/server/MonitoringServer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.server;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpServer;
-import io.micrometer.core.instrument.Meter;
-import io.micrometer.core.instrument.Metrics;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MonitoringServer implements IServer {
-
- private static final Logger logger =
LoggerFactory.getLogger(MonitoringServer.class);
- private static final String SERVER_NAME = "Monitoring Server";
-
- private final String host;
- private final int port;
- private final ObjectMapper objectMapper = new ObjectMapper();
- private HttpServer httpServer;
- private ServiceRegistry serviceRegistry;
- private ServerStatus status = ServerStatus.STOPPED;
-
- public MonitoringServer(String host, int port) {
- this.host = host;
- this.port = port;
- }
-
- public void setServiceRegistry(ServiceRegistry serviceRegistry) {
- this.serviceRegistry = serviceRegistry;
- }
-
- @Override
- public String getName() {
- return SERVER_NAME;
- }
-
- @Override
- public void run() {
- setStatus(ServerStatus.STARTING);
- try {
- logger.info("Starting the monitoring server on {}:{}", host, port);
- httpServer = HttpServer.create(new InetSocketAddress(host, port),
0);
-
- httpServer.createContext("/metrics", this::handleMetrics);
- httpServer.createContext("/health/services",
this::handleHealthServices);
- httpServer.createContext("/admin/restart/",
this::handleAdminRestart);
-
- httpServer.start();
- setStatus(ServerStatus.STARTED);
- logger.info("Monitoring server started on {}:{}", host, port);
-
- // Park thread until interrupted
- while (!Thread.currentThread().isInterrupted()) {
- try {
- Thread.sleep(Long.MAX_VALUE);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- } catch (IOException e) {
- logger.error("Failed to start the monitoring server on host {} and
port {}", host, port, e);
- setStatus(ServerStatus.FAILED);
- }
- }
-
- @Override
- public void stop() {
- setStatus(ServerStatus.STOPPING);
- if (httpServer != null) {
- logger.info("Stopping the monitoring server");
- httpServer.stop(0);
- }
- setStatus(ServerStatus.STOPPED);
- }
-
- @Override
- public ServerStatus getStatus() {
- return status;
- }
-
- private void setStatus(ServerStatus stat) {
- status = stat;
- status.updateTime();
- }
-
- private void handleMetrics(HttpExchange exchange) throws IOException {
- if (!"GET".equalsIgnoreCase(exchange.getRequestMethod())) {
- sendResponse(exchange, 405, "Method Not Allowed");
- return;
- }
- try {
- Map<String, Object> metricsMap = new LinkedHashMap<>();
- for (Meter meter : Metrics.globalRegistry.getMeters()) {
- String name = meter.getId().getName();
- meter.measure()
- .forEach(m -> metricsMap.put(
- name + "." +
m.getStatistic().name().toLowerCase(), m.getValue()));
- }
- sendJson(exchange, 200, metricsMap);
- } catch (Exception e) {
- logger.error("Error serving /metrics", e);
- sendResponse(exchange, 500, "Internal Server Error");
- }
- }
-
- private void handleHealthServices(HttpExchange exchange) throws
IOException {
- if (!"GET".equalsIgnoreCase(exchange.getRequestMethod())) {
- sendResponse(exchange, 405, "Method Not Allowed");
- return;
- }
- try {
- Map<String, ServiceStatus> statuses = serviceRegistry != null ?
serviceRegistry.getStatuses() : Map.of();
- sendJson(exchange, 200, Map.of("services", statuses));
- } catch (Exception e) {
- logger.error("Error serving /health/services", e);
- sendResponse(exchange, 500, "Internal Server Error");
- }
- }
-
- private void handleAdminRestart(HttpExchange exchange) throws IOException {
- if (!"POST".equalsIgnoreCase(exchange.getRequestMethod())) {
- sendResponse(exchange, 405, "Method Not Allowed");
- return;
- }
- String path = exchange.getRequestURI().getPath();
- // path is /admin/restart/{name}
- String prefix = "/admin/restart/";
- if (!path.startsWith(prefix) || path.length() <= prefix.length()) {
- sendJson(exchange, 400, Map.of("error", "Missing service name in
path"));
- return;
- }
- String name = path.substring(prefix.length());
- if (serviceRegistry == null) {
- sendJson(exchange, 500, Map.of("error", "ServiceRegistry not
configured"));
- return;
- }
- try {
- serviceRegistry.restart(name);
- sendJson(exchange, 200, Map.of("status", "restarted", "service",
name));
- } catch (IllegalArgumentException e) {
- sendJson(exchange, 404, Map.of("error", e.getMessage()));
- } catch (IllegalStateException e) {
- sendJson(exchange, 400, Map.of("error", e.getMessage()));
- } catch (Exception e) {
- logger.error("Error restarting service '{}'", name, e);
- sendJson(exchange, 500, Map.of("error", e.getMessage()));
- }
- }
-
- private void sendJson(HttpExchange exchange, int statusCode, Object body)
throws IOException {
- byte[] bytes = objectMapper.writeValueAsBytes(body);
- exchange.getResponseHeaders().set("Content-Type", "application/json");
- exchange.sendResponseHeaders(statusCode, bytes.length);
- try (OutputStream os = exchange.getResponseBody()) {
- os.write(bytes);
- }
- }
-
- private void sendResponse(HttpExchange exchange, int statusCode, String
body) throws IOException {
- byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
- exchange.sendResponseHeaders(statusCode, bytes.length);
- try (OutputStream os = exchange.getResponseBody()) {
- os.write(bytes);
- }
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/server/ServiceRegistry.java
b/airavata-api/src/main/java/org/apache/airavata/server/ServiceRegistry.java
deleted file mode 100644
index 765c7f1614..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/server/ServiceRegistry.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.server;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.function.Supplier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tracks background {@link IServer} instances and their threads, exposing
- * lifecycle operations (status query, restart, stop-all) and error recording.
- */
-public class ServiceRegistry {
-
- private static final Logger logger =
LoggerFactory.getLogger(ServiceRegistry.class);
-
- private static class Entry {
- final IServer server;
- Thread thread;
- final Supplier<IServer> factory;
- final long startedAt;
- String lastError;
-
- Entry(IServer server, Thread thread, Supplier<IServer> factory) {
- this.server = server;
- this.thread = thread;
- this.factory = factory;
- this.startedAt = System.currentTimeMillis();
- }
- }
-
- private final Map<String, Entry> entries = new LinkedHashMap<>();
-
- /**
- * Registers a service with an optional restart factory.
- *
- * @param label human-readable service identifier
- * @param service the IServer instance
- * @param thread the thread running the service
- * @param factory optional supplier to create a fresh IServer for restart;
may be null
- */
- public synchronized void register(String label, IServer service, Thread
thread, Supplier<IServer> factory) {
- entries.put(label, new Entry(service, thread, factory));
- }
-
- /**
- * Registers a service without a restart factory.
- */
- public synchronized void register(String label, IServer service, Thread
thread) {
- register(label, service, thread, null);
- }
-
- /**
- * Returns a snapshot of statuses keyed by label.
- * A service is "UP" if its IServer status is STARTED (preferred) or its
thread is alive.
- * Some services (e.g. PostWorkflowManager) spawn sub-threads and let
their main thread
- * exit — IServer.getStatus() remains STARTED in that case.
- */
- public synchronized Map<String, ServiceStatus> getStatuses() {
- Map<String, ServiceStatus> result = new LinkedHashMap<>();
- long now = System.currentTimeMillis();
- for (Map.Entry<String, Entry> e : entries.entrySet()) {
- Entry entry = e.getValue();
- boolean up = entry.server.getStatus() ==
IServer.ServerStatus.STARTED || entry.thread.isAlive();
- String status = up ? "UP" : "DOWN";
- long uptimeMs = up ? now - entry.startedAt : 0L;
- result.put(e.getKey(), new ServiceStatus(status, uptimeMs,
entry.lastError));
- }
- return result;
- }
-
- /**
- * Attempts to restart the named service using its registered factory.
- *
- * @param name the service label
- * @throws IllegalArgumentException if no service with that name exists
- * @throws IllegalStateException if the service has no restart factory
- * @throws Exception if the new service thread fails to
start
- */
- public synchronized void restart(String name) throws Exception {
- Entry entry = entries.get(name);
- if (entry == null) {
- throw new IllegalArgumentException("No service registered with
name: " + name);
- }
- if (entry.factory == null) {
- throw new IllegalStateException("Service '" + name + "' has no
restart factory");
- }
- // Stop the old instance
- try {
- entry.server.stop();
- } catch (Exception e) {
- logger.warn("Error stopping '{}' before restart: {}", name,
e.getMessage());
- }
- entry.thread.interrupt();
-
- // Start a fresh instance
- IServer newServer = entry.factory.get();
- Thread newThread = new Thread(newServer, "airavata-" + name);
- newThread.setDaemon(true);
- newThread.start();
-
- Entry newEntry = new Entry(newServer, newThread, entry.factory);
- entries.put(name, newEntry);
- logger.info("Service '{}' restarted", name);
- }
-
- /**
- * Records an error message against the named service.
- * Silently ignores unknown names.
- */
- public synchronized void recordError(String name, String errorMessage) {
- Entry entry = entries.get(name);
- if (entry != null) {
- entry.lastError = errorMessage;
- }
- }
-
- /**
- * Stops all registered services and interrupts their threads.
- */
- public synchronized void stopAll() {
- for (Map.Entry<String, Entry> e : entries.entrySet()) {
- String label = e.getKey();
- Entry entry = e.getValue();
- try {
- entry.server.stop();
- } catch (Exception ex) {
- logger.warn("Error stopping '{}': {}", label, ex.getMessage());
- }
- entry.thread.interrupt();
- }
- }
-}
diff --git
a/airavata-api/src/main/java/org/apache/airavata/server/ServiceStatus.java
b/airavata-api/src/main/java/org/apache/airavata/server/ServiceStatus.java
deleted file mode 100644
index 692b0af67b..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/server/ServiceStatus.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.server;
-
-/**
- * DTO representing the runtime status of a single background service.
- */
-public class ServiceStatus {
-
- private String status;
- private long uptimeMs;
- private String lastError;
-
- public ServiceStatus() {}
-
- public ServiceStatus(String status, long uptimeMs, String lastError) {
- this.status = status;
- this.uptimeMs = uptimeMs;
- this.lastError = lastError;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public long getUptimeMs() {
- return uptimeMs;
- }
-
- public void setUptimeMs(long uptimeMs) {
- this.uptimeMs = uptimeMs;
- }
-
- public String getLastError() {
- return lastError;
- }
-
- public void setLastError(String lastError) {
- this.lastError = lastError;
- }
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/util/SwingUtil.java
b/airavata-api/src/main/java/org/apache/airavata/util/SwingUtil.java
deleted file mode 100644
index 07d4dbe43a..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/util/SwingUtil.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.airavata.util;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.net.URL;
-import java.util.List;
-import javax.swing.ImageIcon;
-import javax.swing.JTextField;
-import javax.swing.Spring;
-import javax.swing.SpringLayout;
-
-public class SwingUtil {
-
- /**
- * Minimum size, zero.
- */
- public static final Dimension MINIMUM_SIZE = new Dimension(0, 0);
-
- /**
- * The default distance between components.
- */
- public static final int PAD = 6;
-
- /**
- * Default cursor.
- */
- public static final Cursor DEFAULT_CURSOR = new
Cursor(Cursor.DEFAULT_CURSOR);
-
- /**
- * Hand cursor.
- */
- public static final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
-
- /**
- * Cross hair cursor.
- */
- public static final Cursor CROSSHAIR_CURSOR = new
Cursor(Cursor.CROSSHAIR_CURSOR);
-
- /**
- * Move cursor.
- */
- public static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
-
- /**
- * Wait cursor.
- */
- public static final Cursor WAIT_CURSOR = new Cursor(Cursor.WAIT_CURSOR);
-
- /**
- * Creates an icon from an image contained in the "images" directory.
- *
- * @param filename
- * @return the ImageIcon created
- */
- public static ImageIcon createImageIcon(String filename) {
- ImageIcon icon = null;
- URL imgURL = getImageURL(filename);
- if (imgURL != null) {
- icon = new ImageIcon(imgURL);
- }
- return icon;
- }
-
- /**
- * Creates an image from an image contained in the "images" directory.
- *
- * @param filename
- * @return the Image created
- */
- public static Image createImage(String filename) {
- Image icon = null;
- URL imgURL = getImageURL(filename);
- if (imgURL != null) {
- icon = Toolkit.getDefaultToolkit().getImage(imgURL);
- }
- return icon;
- }
-
- public static URL getImageURL(String filename) {
- String path = "/images/" + filename;
- URL imgURL = SwingUtil.class.getResource(path);
- return imgURL;
- }
-
- /**
- * Return the Frame of a specified component if any.
- *
- * @param component
- * the specified component
- *
- * @return the Frame of a specified component if any; otherwise null
- */
- public static Frame getFrame(Component component) {
- Frame frame;
- Component parent;
- while ((parent = component.getParent()) != null) {
- component = parent;
- }
- if (component instanceof Frame) {
- frame = (Frame) component;
- } else {
- frame = null;
- }
- return frame;
- }
-
- /**
- * Wight none of rows or eolumns. Used by layoutToGrid().
- */
- public static final int WEIGHT_NONE = -1;
-
- /**
- * Weight all rows or columns equally. Used by layoutToGrid().
- */
- public static final int WEIGHT_EQUALLY = -2;
-
- /**
- * Layouts the child components of a specified parent component using
GridBagLayout.
- *
- * @param parent
- * The specified parent component
- * @param numRow
- * The number of rows
- * @param numColumn
- * The number of columns
- * @param weightedRow
- * The row to weight
- * @param weightedColumn
- * The column to weight
- */
- public static void layoutToGrid(Container parent, int numRow, int
numColumn, int weightedRow, int weightedColumn) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD,
SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < numRow; row++) {
- constraints.gridy = row;
- if (weightedRow == WEIGHT_EQUALLY) {
- constraints.weighty = 1;
- } else if (row == weightedRow) {
- constraints.weighty = 1;
- } else {
- constraints.weighty = 0;
- }
- for (int column = 0; column < numColumn; column++) {
- constraints.gridx = column;
- if (weightedColumn == WEIGHT_EQUALLY) {
- constraints.weightx = 1;
- } else if (column == weightedColumn) {
- constraints.weightx = 1;
- } else {
- constraints.weightx = 0;
- }
- Component component = parent.getComponent(row * numColumn +
column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * @param parent
- * @param rowWeights
- * @param columnWeights
- */
- public static void layoutToGrid(Container parent, double[] rowWeights,
double[] columnWeights) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD,
SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < rowWeights.length; row++) {
- constraints.gridy = row;
- constraints.weighty = rowWeights[row];
- for (int column = 0; column < columnWeights.length; column++) {
- constraints.gridx = column;
- constraints.weightx = columnWeights[column];
- Component component = parent.getComponent(row *
columnWeights.length + column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * @param parent
- * @param rowWeights
- * @param columnWeights
- */
- @SuppressWarnings("boxing")
- public static void layoutToGrid(Container parent, List<Double> rowWeights,
List<Double> columnWeights) {
- GridBagLayout layout = new GridBagLayout();
- parent.setLayout(layout);
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets(SwingUtil.PAD, SwingUtil.PAD,
SwingUtil.PAD, SwingUtil.PAD);
-
- for (int row = 0; row < rowWeights.size(); row++) {
- constraints.gridy = row;
- constraints.weighty = rowWeights.get(row);
- for (int column = 0; column < columnWeights.size(); column++) {
- constraints.gridx = column;
- constraints.weightx = columnWeights.get(column);
- Component component = parent.getComponent(row *
columnWeights.size() + column);
- layout.setConstraints(component, constraints);
- }
- }
- }
-
- /**
- * Aligns the first <code>rows</code> * <code>cols</code> components of
<code>parent</code> in a grid. Each
- * component in a column is as wide as the maximum preferred width of the
components in that column; height is
- * similarly determined for each row. The parent is made just big enough
to fit them all.
- *
- * @param parent
- *
- * @param rows
- * number of rows
- * @param cols
- * number of columns
- */
- public static void makeSpringCompactGrid(Container parent, int rows, int
cols) {
- makeSpringCompactGrid(parent, rows, cols, PAD, PAD, PAD, PAD);
- }
-
- /**
- * Aligns the first <code>rows</code> * <code>cols</code> components of
<code>parent</code> in a grid. Each
- * component in a column is as wide as the maximum preferred width of the
components in that column; height is
- * similarly determined for each row. The parent is made just big enough
to fit them all.
- *
- * @param parent
- *
- * @param rows
- * number of rows
- * @param cols
- * number of columns
- * @param initialX
- * x location to start the grid at
- * @param initialY
- * y location to start the grid at
- * @param xPad
- * x padding between cells
- * @param yPad
- * y padding between cells
- */
- private static void makeSpringCompactGrid(
- Container parent, int rows, int cols, int initialX, int initialY,
int xPad, int yPad) {
-
- SpringLayout layout = new SpringLayout();
- parent.setLayout(layout);
-
- // Align all cells in each column and make them the same width.
- Spring x = Spring.constant(initialX);
- for (int c = 0; c < cols; c++) {
- Spring width = Spring.constant(0);
- for (int r = 0; r < rows; r++) {
- width = Spring.max(
- width, getConstraintsForCell(r, c, parent,
cols).getWidth());
- }
- for (int r = 0; r < rows; r++) {
- SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
- constraints.setX(x);
- constraints.setWidth(width);
- }
- x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
- }
-
- // Align all cells in each row and make them the same height.
- Spring y = Spring.constant(initialY);
- for (int r = 0; r < rows; r++) {
- Spring height = Spring.constant(0);
- for (int c = 0; c < cols; c++) {
- height = Spring.max(
- height, getConstraintsForCell(r, c, parent,
cols).getHeight());
- }
- for (int c = 0; c < cols; c++) {
- SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
- constraints.setY(y);
- constraints.setHeight(height);
- }
- y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
- }
-
- // Set the parent's size.
- SpringLayout.Constraints pCons = layout.getConstraints(parent);
- pCons.setConstraint(SpringLayout.SOUTH, y);
- pCons.setConstraint(SpringLayout.EAST, x);
- }
-
- /* Used by makeCompactGrid. */
- private static SpringLayout.Constraints getConstraintsForCell(int row, int
col, Container parent, int cols) {
- SpringLayout layout = (SpringLayout) parent.getLayout();
- Component c = parent.getComponent(row * cols + col);
- return layout.getConstraints(c);
- }
-
- public static void addPlaceHolder(final JTextField field, final String
placeHolderText) {
- field.addFocusListener(new FocusListener() {
- private Color fontColor = field.getForeground();
- // private String previousText=field.getText();
-
- public void focusGained(FocusEvent arg0) {
- if (field.getText().equals(placeHolderText)) {
- field.setText("");
- }
- field.setForeground(fontColor);
- }
-
- public void focusLost(FocusEvent arg0) {
- if (field.getText().trim().equals("")) {
- fontColor = field.getForeground();
- field.setForeground(Color.GRAY);
- field.setText(placeHolderText);
- }
- }
- });
- if (field.getText().trim().equals("")) {
- field.setText(placeHolderText);
- field.setForeground(Color.GRAY);
- }
- }
-}