http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java deleted file mode 100644 index 9477cc9..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java +++ /dev/null @@ -1,677 +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.common.logger; - -public interface AiravataLogger{ - - /** - * Return the name of this <code>Logger</code> instance. - * - * @return name of this logger instance - */ - String getName(); - - /** - * Is the logger instance enabled for the TRACE level? - * - * @return True if this Logger is enabled for the TRACE level, - * false otherwise. - * @since 1.4 - */ - boolean isTraceEnabled(); - - /** - * Log a message at the TRACE level. - * - * @param msg the message string to be logged - * @since 1.4 - */ - void trace(String msg); - - /** - * Log a message at the TRACE level. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message string to be logged - * @since 1.4 - */ - void traceId(String etjId, String msg); - - /** - * Log a message at the TRACE level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the TRACE level. </p> - * - * @param format the format string - * @param arg the argument - * @since 1.4 - */ - void trace(String format, Object arg); - - /** - * Log a message at the TRACE level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the TRACE level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg the argument - * @since 1.4 - */ - void traceId(String etjId, String format, Object arg); - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the TRACE level. </p> - * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - * @since 1.4 - */ - void trace(String format, Object arg1, Object arg2); - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the TRACE level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - * @since 1.4 - */ - void traceId(String etjId, String format, Object arg1, Object arg2); - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the TRACE level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and - * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p> - * - * @param format the format string - * @param arguments a list of 3 or more arguments - * @since 1.4 - */ - void trace(String format, Object... arguments); - - /** - * Log a message at the TRACE level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the TRACE level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and - * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arguments a list of 3 or more arguments - * @since 1.4 - */ - void traceId(String etjId, String format, Object... arguments); - - /** - * Log an exception (throwable) at the TRACE level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - * @since 1.4 - */ - void trace(String msg, Throwable t); - - /** - * Log an exception (throwable) at the TRACE level with an - * accompanying message. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - * @since 1.4 - */ - void traceId(String etjId, String msg, Throwable t); - - /** - * Is the logger instance enabled for the DEBUG level? - * - * @return True if this Logger is enabled for the DEBUG level, - * false otherwise. - */ - boolean isDebugEnabled(); - - /** - * Log a message at the DEBUG level. - * - * @param msg the message string to be logged - */ - void debug(String msg); - - /** - * Log a message at the DEBUG level. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message string to be logged - */ - void debugId(String etjId, String msg); - - /** - * Log a message at the DEBUG level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level. </p> - * - * @param format the format string - * @param arg the argument - */ - void debug(String format, Object arg); - - /** - * Log a message at the DEBUG level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg the argument - */ - void debugId(String etjId, String format, Object arg); - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level. </p> - * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void debug(String format, Object arg1, Object arg2); - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the DEBUG level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void debugId(String etjId, String format, Object arg1, Object arg2); - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the DEBUG level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for DEBUG. The variants taking - * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void debug(String format, Object... arguments); - - /** - * Log a message at the DEBUG level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the DEBUG level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for DEBUG. The variants taking - * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void debugId(String etjId, String format, Object... arguments); - - /** - * Log an exception (throwable) at the DEBUG level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void debug(String msg, Throwable t); - - /** - * Log an exception (throwable) at the DEBUG level with an - * accompanying message. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void debugId(String etjId, String msg, Throwable t); - - /** - * Is the logger instance enabled for the INFO level? - * - * @return True if this Logger is enabled for the INFO level, - * false otherwise. - */ - boolean isInfoEnabled(); - - /** - * Log a message at the INFO level. - * - * @param msg the message string to be logged - */ - void info(String msg); - - /** - * Log a message at the INFO level. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message string to be logged - */ - void infoId(String etjId, String msg); - - /** - * Log a message at the INFO level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the INFO level. </p> - * - * @param format the format string - * @param arg the argument - */ - void info(String format, Object arg); - - /** - * Log a message at the INFO level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the INFO level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg the argument - */ - void infoId(String etjId, String format, Object arg); - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the INFO level. </p> - * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void info(String format, Object arg1, Object arg2); - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the INFO level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void infoId(String etjId, String format, Object arg1, Object arg2); - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the INFO level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for INFO. The variants taking - * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void info(String format, Object... arguments); - - /** - * Log a message at the INFO level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the INFO level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for INFO. The variants taking - * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void infoId(String etjId, String format, Object... arguments); - - /** - * Log an exception (throwable) at the INFO level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void info(String msg, Throwable t); - - /** - * Log an exception (throwable) at the INFO level with an - * accompanying message. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void infoId(String etjId, String msg, Throwable t); - - /** - * Is the logger instance enabled for the WARN level? - * - * @return True if this Logger is enabled for the WARN level, - * false otherwise. - */ - boolean isWarnEnabled(); - - /** - * Log a message at the WARN level. - * - * @param msg the message string to be logged - */ - void warn(String msg); - - /** - * Log a message at the WARN level. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message string to be logged - */ - void warnId(String etjId, String msg); - - /** - * Log a message at the WARN level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the WARN level. </p> - * - * @param format the format string - * @param arg the argument - */ - void warn(String format, Object arg); - - /** - * Log a message at the WARN level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the WARN level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg the argument - */ - void warnId(String etjId, String format, Object arg); - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the WARN level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for WARN. The variants taking - * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void warn(String format, Object... arguments); - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the WARN level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for WARN. The variants taking - * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void warnId(String etjId, String format, Object... arguments); - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the WARN level. </p> - * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void warn(String format, Object arg1, Object arg2); - - /** - * Log a message at the WARN level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the WARN level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void warnId(String etjId, String format, Object arg1, Object arg2); - - /** - * Log an exception (throwable) at the WARN level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void warn(String msg, Throwable t); - - /** - * Log an exception (throwable) at the WARN level with an - * accompanying message. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void warnId(String etjId, String msg, Throwable t); - - /** - * Is the logger instance enabled for the ERROR level? - * - * @return True if this Logger is enabled for the ERROR level, - * false otherwise. - */ - boolean isErrorEnabled(); - - /** - * Log a message at the ERROR level. - * - * @param msg the message string to be logged - */ - void error(String msg); - - /** - * Log a message at the ERROR level. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message string to be logged - */ - void errorId(String etjId, String msg); - - /** - * Log a message at the ERROR level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the ERROR level. </p> - * - * @param format the format string - * @param arg the argument - */ - void error(String format, Object arg); - - /** - * Log a message at the ERROR level according to the specified format - * and argument. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the ERROR level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg the argument - */ - void errorId(String etjId, String format, Object arg); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the ERROR level. </p> - * - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void error(String format, Object arg1, Object arg2); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous object creation when the logger - * is disabled for the ERROR level. </p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arg1 the first argument - * @param arg2 the second argument - */ - void errorId(String etjId, String format, Object arg1, Object arg2); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the ERROR level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for ERROR. The variants taking - * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void error(String format, Object... arguments); - - /** - * Log a message at the ERROR level according to the specified format - * and arguments. - * <p/> - * <p>This form avoids superfluous string concatenation when the logger - * is disabled for the ERROR level. However, this variant incurs the hidden - * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, - * even if this logger is disabled for ERROR. The variants taking - * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} - * arguments exist solely in order to avoid this hidden cost.</p> - * - * @param etjId - Experiment , Task or Job Id - * @param format the format string - * @param arguments a list of 3 or more arguments - */ - void errorId(String etjId, String format, Object... arguments); - - /** - * Log an exception (throwable) at the ERROR level with an - * accompanying message. - * - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void error(String msg, Throwable t); - - /** - * Log an exception (throwable) at the ERROR level with an - * accompanying message. - * - * @param etjId - Experiment , Task or Job Id - * @param msg the message accompanying the exception - * @param t the exception (throwable) to log - */ - void errorId(String etjId, String msg, Throwable t); - -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java deleted file mode 100644 index a1a9462..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java +++ /dev/null @@ -1,34 +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.common.logger; - -public class AiravataLoggerFactory { - - public static AiravataLogger getLogger(Class aClass) { - return new AiravataLoggerImpl(aClass); - } - - public static AiravataLogger getLogger(String className) { - return new AiravataLoggerImpl(className); - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java deleted file mode 100644 index 74ab401..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java +++ /dev/null @@ -1,323 +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.common.logger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AiravataLoggerImpl implements AiravataLogger{ - - private Logger logger; - - public AiravataLoggerImpl(Class aClass) { - logger = LoggerFactory.getLogger(aClass); - } - - public AiravataLoggerImpl(String className) { - logger = LoggerFactory.getLogger(className); - } - - - @Override - public String getName() { - return logger.getName(); - } - - @Override - public boolean isTraceEnabled() { - return logger.isTraceEnabled(); - } - - @Override - public void trace(String msg) { - logger.trace(msg); - } - - @Override - public void traceId(String etjId, String msg) { - logger.trace(getAiravataLogMessage(etjId, msg)); - } - - @Override - public void trace(String format, Object arg) { - logger.trace(format, arg); - } - - @Override - public void traceId(String etjId, String format, Object arg) { - logger.trace(getAiravataLogMessage(etjId, format), arg); - } - - @Override - public void trace(String format, Object arg1, Object arg2) { - logger.trace(format, arg1, arg2); - } - - @Override - public void traceId(String etjId, String format, Object arg1, Object arg2) { - logger.trace(getAiravataLogMessage(etjId,format), arg1, arg2); - } - - @Override - public void trace(String format, Object... arguments) { - logger.trace(format, arguments); - } - - @Override - public void traceId(String etjId, String format, Object... arguments) { - logger.trace(getAiravataLogMessage(etjId, format), arguments); - } - - @Override - public void trace(String msg, Throwable t) { - logger.trace(msg, t); - } - - @Override - public void traceId(String etjId, String msg, Throwable t) { - logger.trace(getAiravataLogMessage(etjId, msg), t); - } - - @Override - public boolean isDebugEnabled() { - return logger.isDebugEnabled(); - } - - @Override - public void debug(String msg) { - logger.debug(msg); - } - - @Override - public void debugId(String etjId, String msg) { - logger.debug(getAiravataLogMessage(etjId, msg)); - } - - @Override - public void debug(String format, Object arg) { - logger.debug(format, arg); - } - - @Override - public void debugId(String etjId, String format, Object arg) { - logger.debug(getAiravataLogMessage(etjId, format), arg); - } - - @Override - public void debug(String format, Object arg1, Object arg2) { - logger.debug(format, arg1, arg2); - } - - @Override - public void debugId(String etjId, String format, Object arg1, Object arg2) { - logger.debug(getAiravataLogMessage(etjId, format), arg1, arg2); - } - - @Override - public void debug(String format, Object... arguments) { - logger.debug(format, arguments); - } - - @Override - public void debugId(String etjId, String format, Object... arguments) { - logger.debug(getAiravataLogMessage(etjId, format), arguments); - } - - @Override - public void debug(String msg, Throwable t) { - logger.debug(msg, t); - } - - @Override - public void debugId(String etjId, String msg, Throwable t) { - logger.debug(getAiravataLogMessage(etjId, msg), t); - } - - @Override - public boolean isInfoEnabled() { - return logger.isInfoEnabled(); - } - - @Override - public void info(String msg) { - logger.info(msg); - } - - @Override - public void infoId(String etjId, String msg) { - logger.info(getAiravataLogMessage(etjId, msg)); - } - - @Override - public void info(String format, Object arg) { - logger.info(format, arg); - } - - @Override - public void infoId(String etjId, String format, Object arg) { - logger.info(getAiravataLogMessage(etjId, format), arg); - } - - @Override - public void info(String format, Object arg1, Object arg2) { - logger.info(format, arg1, arg2); - } - - @Override - public void infoId(String etjId, String format, Object arg1, Object arg2) { - logger.info(getAiravataLogMessage(etjId, format), arg1, arg2); - } - - @Override - public void info(String format, Object... arguments) { - logger.info(format, arguments); - } - - @Override - public void infoId(String etjId, String format, Object... arguments) { - logger.info(getAiravataLogMessage(etjId, format), arguments); - } - - @Override - public void info(String msg, Throwable t) { - logger.info(msg, t); - } - - @Override - public void infoId(String etjId, String msg, Throwable t) { - logger.info(getAiravataLogMessage(etjId, msg), t); - } - - @Override - public boolean isWarnEnabled() { - return logger.isWarnEnabled(); - } - - @Override - public void warn(String msg) { - logger.warn(msg); - } - - @Override - public void warnId(String etjId, String msg) { - logger.warn(getAiravataLogMessage(etjId, msg)); - } - - @Override - public void warn(String format, Object arg) { - logger.warn(format, arg); - } - - @Override - public void warnId(String etjId, String format, Object arg) { - logger.warn(getAiravataLogMessage(etjId, format), arg); - } - - @Override - public void warn(String format, Object... arguments) { - logger.warn(format, arguments); - } - - @Override - public void warnId(String etjId, String format, Object... arguments) { - logger.warn(getAiravataLogMessage(etjId, format), arguments); - } - - @Override - public void warn(String format, Object arg1, Object arg2) { - logger.warn(format, arg1, arg2); - } - - @Override - public void warnId(String etjId, String format, Object arg1, Object arg2) { - logger.warn(getAiravataLogMessage(etjId, format), arg1, arg2); - } - - @Override - public void warn(String msg, Throwable t) { - logger.warn(msg, t); - } - - @Override - public void warnId(String etjId, String msg, Throwable t) { - logger.warn(getAiravataLogMessage(etjId, msg), t); - } - - @Override - public boolean isErrorEnabled() { - return logger.isErrorEnabled(); - } - - @Override - public void error(String msg) { - logger.error(msg); - } - - @Override - public void errorId(String etjId, String msg) { - logger.error(getAiravataLogMessage(etjId, msg)); - } - - @Override - public void error(String format, Object arg) { - logger.error(format, arg); - } - - @Override - public void errorId(String etjId, String format, Object arg) { - logger.error(getAiravataLogMessage(etjId, format), arg); - } - - @Override - public void error(String format, Object arg1, Object arg2) { - logger.error(format, arg1, arg2); - } - - @Override - public void errorId(String etjId, String format, Object arg1, Object arg2) { - logger.error(getAiravataLogMessage(etjId, format), arg1, arg2); - } - - @Override - public void error(String format, Object... arguments) { - logger.error(format, arguments); - } - - @Override - public void errorId(String etjId, String format, Object... arguments) { - logger.error(getAiravataLogMessage(etjId, format), arguments); - } - - @Override - public void error(String msg, Throwable t) { - logger.error(msg, t); - } - - @Override - public void errorId(String etjId, String msg, Throwable t) { - logger.error(getAiravataLogMessage(etjId, msg), t); - } - - private String getAiravataLogMessage(String etjId, String msg) { - return new StringBuilder("Id:").append(etjId).append(" : ").append(msg).toString(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java deleted file mode 100644 index 83e4218..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java +++ /dev/null @@ -1,117 +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.common.utils; - -/* -These are the job statuses shared in database level between orchestrator and -gfac instances - */ -public class AiravataJobState { - - private State jobState; - - public State getJobState() { - return jobState; - } - - public void setJobState(State jobState) { - this.jobState = jobState; - } - - - public enum State { - CREATED { - public String toString() { - return "CREATED"; - } - }, - ACCEPTED { - public String toString() { - return "ACCEPTED"; - } - }, - FETCHED { - public String toString() { - return "FETCHED"; - } - }, - INHANDLERSDONE { - public String toString() { - return "INHANDLERSDONE"; - } - }, - SUBMITTED { - public String toString() { - return "SUBMITTED"; - } - }, - OUTHANDLERSDONE { - public String toString() { - return "OUTHANDLERSDONE"; - } - }, - RUNNING { - public String toString() { - return "RUNNING"; - } - }, - FAILED { - public String toString() { - return "FAILED"; - } - }, - PAUSED { - public String toString() { - return "PAUSED"; - } - }, - PENDING { - public String toString() { - return "PENDING"; - } - }, - ACTIVE { - public String toString() { - return "ACTIVE"; - } - }, - DONE { - public String toString() { - return "DONE"; - } - }, - CANCELLED { - public String toString() { - return "CANCELLED"; - } - }, - UNKNOWN { - public String toString() { - return "UNKNOWN"; - } - }, - HANGED { - public String toString() { - return "HANGED"; - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java deleted file mode 100644 index 52d114f..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java +++ /dev/null @@ -1,47 +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.common.utils; - -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.UUID; - -public class AiravataUtils { - - public static Timestamp getCurrentTimestamp() { - Calendar calender = Calendar.getInstance(); - java.util.Date d = calender.getTime(); - return new Timestamp(d.getTime()); - } - - public static Timestamp getTime(long time) { - if (time == 0 || time < 0){ - return getCurrentTimestamp(); - } - return new Timestamp(time); - } - - public static String getId (String name){ - String id = name.replaceAll("\\s", ""); - return id + "_" + UUID.randomUUID(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java deleted file mode 100644 index f753bc1..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java +++ /dev/null @@ -1,205 +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.common.utils; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.curator.framework.CuratorFramework; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; -import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.server.ServerCnxnFactory; -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServer; -import org.apache.zookeeper.server.persistence.FileTxnSnapLog; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.ByteBuffer; - -public class AiravataZKUtils implements Watcher { - private final static Logger logger = LoggerFactory.getLogger(AiravataZKUtils.class); - - public static final String ZK_EXPERIMENT_STATE_NODE = "state"; - public static final String DELIVERY_TAG_POSTFIX = "-deliveryTag"; - public static final String CANCEL_DELIVERY_TAG_POSTFIX = "-cancel-deliveryTag"; - - @Override - public void process(WatchedEvent event) { - - } - - public static String getExpZnodePath(String experimentId) throws ApplicationSettingsException { - return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) + - File.separator + - ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator - + experimentId; - } - - public static String getExpZnodeHandlerPath(String experimentId, String className) throws ApplicationSettingsException { - return ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE) + - File.separator + - ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator - + experimentId + File.separator + className; - } - - public static String getZKhostPort() throws ApplicationSettingsException { - return ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_HOST,"localhost") - + ":" + ServerSettings.getSetting(Constants.ZOOKEEPER_SERVER_PORT,"2181"); - } - - public static int getZKTimeout()throws ApplicationSettingsException { - return Integer.parseInt(ServerSettings.getSetting(Constants.ZOOKEEPER_TIMEOUT,"30000")); - } - - public static String getExpStatePath(String experimentId) throws ApplicationSettingsException { - return AiravataZKUtils.getExpZnodePath(experimentId) + - File.separator + - "state"; - } - - public static String getExpState(CuratorFramework curatorClient, String expId) throws Exception { - Stat exists = curatorClient.checkExists().forPath(getExpStatePath(expId)); - if (exists != null) { - return new String(curatorClient.getData().storingStatIn(exists).forPath(getExpStatePath(expId))); - } - return null; - } - - public static void runZKFromConfig(ServerConfig config,ServerCnxnFactory cnxnFactory) throws IOException { - AiravataZKUtils.logger.info("Starting Zookeeper server..."); - FileTxnSnapLog txnLog = null; - try { - // Note that this thread isn't going to be doing anything else, - // so rather than spawning another thread, we will just call - // run() in this thread. - // create a file logger url from the command line args - ZooKeeperServer zkServer = new ZooKeeperServer(); - - txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File( - config.getDataDir())); - zkServer.setTxnLogFactory(txnLog); - zkServer.setTickTime(config.getTickTime()); - zkServer.setMinSessionTimeout(config.getMinSessionTimeout()); - zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout()); - cnxnFactory = ServerCnxnFactory.createFactory(); - cnxnFactory.configure(config.getClientPortAddress(), - config.getMaxClientCnxns()); - cnxnFactory.startup(zkServer); - cnxnFactory.join(); - if (zkServer.isRunning()) { - zkServer.shutdown(); - } - } catch (InterruptedException e) { - // warn, but generally this is ok - AiravataZKUtils.logger.warn("Server interrupted", e); - System.exit(1); - } finally { - if (txnLog != null) { - txnLog.close(); - } - } - } - - public static void startEmbeddedZK(ServerCnxnFactory cnxnFactory) { - if (ServerSettings.isEmbeddedZK()) { - ServerConfig serverConfig = new ServerConfig(); - URL resource = AiravataZKUtils.class.getClassLoader().getResource("zoo.cfg"); - if (resource == null) { - logger.error("There is no zoo.cfg file in the classpath... Failed to start Zookeeper Server"); - System.exit(1); - } - try { - serverConfig.parse(resource.getPath()); - } catch (QuorumPeerConfig.ConfigException e) { - logger.error("Error while starting embedded Zookeeper", e); - System.exit(2); - } - - final ServerConfig fServerConfig = serverConfig; - final ServerCnxnFactory fserverCnxnFactory = cnxnFactory; - (new Thread() { - public void run() { - try { - AiravataZKUtils.runZKFromConfig(fServerConfig,fserverCnxnFactory); - } catch (IOException e) { - logger.error("Error while starting embedded Zookeeper", e); - System.exit(3); - } - } - }).start(); - }else{ - logger.info("Skipping Zookeeper embedded startup ..."); - } - } - - public static byte[] toByteArray(double value) { - byte[] bytes = new byte[8]; - ByteBuffer.wrap(bytes).putDouble(value); - return bytes; - } - - public static long getDeliveryTag(String experimentID, CuratorFramework curatorClient, String experimentNode, - String pickedChild) throws Exception { - String deliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentID - + DELIVERY_TAG_POSTFIX; - Stat exists = curatorClient.checkExists().forPath(deliveryTagPath); - if(exists==null) { - logger.error("Cannot find delivery Tag in path:" + deliveryTagPath + " for this experiment"); - return -1; - } - return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(deliveryTagPath)); - } - public static byte[] longToBytes(long x) { - ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); - buffer.putLong(x); - return buffer.array(); - } - - public static long bytesToLong(byte[] bytes) { - ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); - buffer.put(bytes); - buffer.flip();//need flip - return buffer.getLong(); - } - - public static double toDouble(byte[] bytes) { - return ByteBuffer.wrap(bytes).getDouble(); - } - - public static long getCancelDeliveryTagIfExist(String experimentId, CuratorFramework curatorClient, - String experimentNode, String pickedChild) throws Exception { - - String cancelDeliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentId + - AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX; - Stat exists = curatorClient.checkExists().forPath(cancelDeliveryTagPath); - if (exists == null) { - return -1; // no cancel deliverytag found - } else { - return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(cancelDeliveryTagPath)); - } - - - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java deleted file mode 100644 index 9a59573..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java +++ /dev/null @@ -1,444 +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.common.utils; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.exception.ApplicationSettingsLoadException; -import org.apache.airavata.common.exception.ApplicationSettingsStoreException; -import org.apache.airavata.common.exception.UnspecifiedApplicationSettingsException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ApplicationSettings { - public static final String SERVER_PROPERTIES="airavata-server.properties"; - - public static String ADDITIONAL_SETTINGS_FILES = "external.settings"; - - protected Properties properties = new Properties(); - private Exception propertyLoadException; - - - protected static final String TRUST_STORE_PATH="trust.store"; - protected static final String TRUST_STORE_PASSWORD="trust.store.password"; - - private static final String REGULAR_EXPRESSION = "\\$\\{[a-zA-Z.-]*\\}"; - - private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class); - - private static final String SHUTDOWN_STATEGY_STRING="shutdown.strategy"; - - protected static ApplicationSettings INSTANCE; - public static enum ShutdownStrategy{ - NONE, - SELF_TERMINATE - } - { - loadProperties(); - } - - private void loadProperties() { - URL url = getPropertyFileURL(); - try { - - properties.load(url.openStream()); - logger.info("Settings loaded from "+url.toString()); - URL[] externalSettingsFileURLs = getExternalSettingsFileURLs(); - for (URL externalSettings : externalSettingsFileURLs) { - mergeSettingsImpl(externalSettings.openStream()); - logger.info("External settings merged from "+url.toString()); - } - } catch (Exception e) { - propertyLoadException=e; - } - } - - protected URL getPropertyFileURL() { - return ApplicationSettings.class.getClassLoader().getResource(SERVER_PROPERTIES); - } - - protected URL[] getExternalSettingsFileURLs(){ - try { - List<URL> externalSettingsFileURLs=new ArrayList<URL>(); - String externalSettingsFileNames = getSettingImpl(ADDITIONAL_SETTINGS_FILES); - String[] externalSettingFiles = externalSettingsFileNames.split(","); - for (String externalSettingFile : externalSettingFiles) { - URL externalSettingFileURL = ApplicationSettings.class.getClassLoader().getResource(externalSettingFile); - if (externalSettingFileURL==null){ - logger.warn("Could not file external settings file "+externalSettingFile); - }else{ - externalSettingsFileURLs.add(externalSettingFileURL); - } - } - return externalSettingsFileURLs.toArray(new URL[]{}); - } catch (ApplicationSettingsException e) { - return new URL[]{}; - } - } - protected static ApplicationSettings getInstance(){ - if (INSTANCE==null){ - INSTANCE=new ApplicationSettings(); - } - return INSTANCE; - } - - protected static void setInstance(ApplicationSettings settingsInstance){ - INSTANCE=settingsInstance; - } - - private void saveProperties() throws ApplicationSettingsStoreException{ - URL url = getPropertyFileURL(); - if (url.getProtocol().equalsIgnoreCase("file")){ - try { - properties.store(new FileOutputStream(url.getPath()), Calendar.getInstance().toString()); - } catch (Exception e) { - throw new ApplicationSettingsStoreException(url.getPath(), e); - } - }else{ - logger.warn("Properties cannot be updated to location "+url.toString()); - } - } - - private void validateSuccessfulPropertyFileLoad() throws ApplicationSettingsException{ - if (propertyLoadException!=null){ - throw new ApplicationSettingsLoadException(propertyLoadException); - } - } - - /** - * Returns the configuration value relevant for the given key. - * If configuration value contains references to other configuration values they will also - * be replaced. E.g :- If configuration key reads http://${ip}:${port}/axis2/services/RegistryService?wsdl, - * the variables ip and port will get replaced by their appropriated values in the configuration. - * @param key The configuration key to read value of - * @return The configuration value. For above example caller will get a value like - * http://192.2.33.12:8080/axis2/services/RegistryService?wsdl - * @throws ApplicationSettingsException If an error occurred while reading configurations. - * @deprecated use #getSetting(String) instead - */ - public String getAbsoluteSetting(String key) throws ApplicationSettingsException { - - String configurationValueWithVariables = ApplicationSettings.getSetting(key); - - List<String> variableList - = getAllMatches(configurationValueWithVariables, REGULAR_EXPRESSION); - - if (variableList == null || variableList.isEmpty()) { - return configurationValueWithVariables; - } - - for(String variableIdentifier : variableList) { - String variableName = getVariableNameOnly(variableIdentifier); - String value = getAbsoluteSetting(variableName); - - configurationValueWithVariables = configurationValueWithVariables.replace(variableIdentifier, value); - } - - return configurationValueWithVariables; - - } - - private static String getVariableNameOnly(String variableWithIdentifiers) { - return variableWithIdentifiers.substring(2, (variableWithIdentifiers.length() - 1)); - } - - private static List<String> getAllMatches(String text, String regex) { - List<String> matches = new ArrayList<String>(); - Matcher m = Pattern.compile("(?=(" + regex + "))").matcher(text); - while(m.find()) { - matches.add(m.group(1)); - } - return matches; - } - - public String getSettingImpl(String key) throws ApplicationSettingsException{ - String rawValue=null; - if (System.getProperties().containsKey(key)){ - rawValue=System.getProperties().getProperty(key); - }else{ - validateSuccessfulPropertyFileLoad(); - if (properties.containsKey(key)){ - rawValue=properties.getProperty(key); - }else{ - throw new UnspecifiedApplicationSettingsException(key); - } - } - return deriveAbsoluteValueImpl(rawValue); - } - - public String getSettingImpl(String key, String defaultValue){ - try { - return getSettingImpl(key); - } catch (ApplicationSettingsException e) { - //we'll ignore this error since a default value is provided - } - return defaultValue; - } - - private String deriveAbsoluteValueImpl(String property){ - if (property!=null){ - Map<Integer, String> containedParameters = StringUtil.getContainedParameters(property); - List<String> parametersAlreadyProcessed=new ArrayList<String>(); - for (String parameter : containedParameters.values()) { - if (!parametersAlreadyProcessed.contains(parameter)) { - String parameterName = parameter.substring(2,parameter.length() - 1); - String parameterValue = getSetting(parameterName,parameter); - property = property.replaceAll(Pattern.quote(parameter), parameterValue); - parametersAlreadyProcessed.add(parameter); - } - } - } - return property; - } - - public void setSettingImpl(String key, String value) throws ApplicationSettingsException{ - properties.setProperty(key, value); - saveProperties(); - } - - public boolean isSettingDefinedImpl(String key) throws ApplicationSettingsException{ - validateSuccessfulPropertyFileLoad(); - return properties.containsKey(key); - } - - public String getTrustStorePathImpl() throws ApplicationSettingsException { - return getSetting(TRUST_STORE_PATH); - } - - public String getTrustStorePasswordImpl() throws ApplicationSettingsException { - return getSetting(TRUST_STORE_PASSWORD); - } - - public String getCredentialStoreKeyStorePathImpl() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.url"); - } - - public String getCredentialStoreKeyAliasImpl() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.alias"); - } - - public String getCredentialStoreKeyStorePasswordImpl() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.password"); - } - - public String getCredentialStoreNotifierEnabledImpl() throws ApplicationSettingsException { - return getSetting("notifier.enabled"); - } - - public String getCredentialStoreNotifierDurationImpl() throws ApplicationSettingsException { - return getSetting("notifier.duration"); - } - - public String getCredentialStoreEmailServerImpl() throws ApplicationSettingsException { - return getSetting("email.server"); - } - - public String getCredentialStoreEmailServerPortImpl() throws ApplicationSettingsException { - return getSetting("email.server.port"); - } - - public String getCredentialStoreEmailUserImpl() throws ApplicationSettingsException { - return getSetting("email.user"); - } - - public String getCredentialStoreEmailPasswordImpl() throws ApplicationSettingsException { - return getSetting("email.password"); - } - - public String getCredentialStoreEmailSSLConnectImpl() throws ApplicationSettingsException { - return getSetting("email.ssl"); - } - - public String getCredentialStoreEmailFromEmailImpl() throws ApplicationSettingsException { - return getSetting("email.from"); - } - - /** - * @deprecated use {{@link #getSetting(String)}} - * @return - */ - public Properties getPropertiesImpl() { - return properties; - } - - public void mergeSettingsImpl(Map<String,String> props){ - properties.putAll(props); - } - - public void mergeSettingsImpl(InputStream stream) throws IOException{ - Properties tmpProp = new Properties(); - tmpProp.load(stream); - properties.putAll(tmpProp); - } - - public void mergeSettingsCommandLineArgsImpl(String[] args){ - properties.putAll(StringUtil.parseCommandLineOptions(args)); - } - - public ShutdownStrategy getShutdownStrategyImpl() throws Exception{ - String strategy = null; - try { - strategy = getSetting(SHUTDOWN_STATEGY_STRING, ShutdownStrategy.SELF_TERMINATE.toString()); - return ShutdownStrategy.valueOf(strategy); - } catch (Exception e) { - //if the string mentioned in config is invalid - throw new Exception("Invalid shutdown strategy configured : "+strategy); - } - } - - /* - * Static methods which will be used by the users - */ - - public static String getSetting(String key) throws ApplicationSettingsException{ - return getInstance().getSettingImpl(key); - } - - public static String getSetting(String key, String defaultValue){ - return getInstance().getSettingImpl(key,defaultValue); - - } - - public static void setSetting(String key, String value) throws ApplicationSettingsException{ - getInstance().properties.setProperty(key, value); - getInstance().saveProperties(); - } - - public static boolean isSettingDefined(String key) throws ApplicationSettingsException{ - return getInstance().properties.containsKey(key); - } - - public static String getTrustStorePath() throws ApplicationSettingsException { - return getSetting(TRUST_STORE_PATH); - } - - public static String getTrustStorePassword() throws ApplicationSettingsException { - return getSetting(TRUST_STORE_PASSWORD); - } - - public static void initializeTrustStore() throws ApplicationSettingsException { - SecurityUtil.setTrustStoreParameters(getTrustStorePath(), getTrustStorePassword()); - } - - public static String getCredentialStoreKeyStorePath() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.url"); - } - - public static String getCredentialStoreThriftServerKeyStorePath() throws ApplicationSettingsException { - return getSetting("credential.store.thrift.server.keystore"); - } - - public static boolean isCredentialStoreStartEnabled() throws ApplicationSettingsException { - String enableCredentialStore = getSetting("start.credential.store"); - if (enableCredentialStore.equals("true")){ - return true; - } - return false; - } - - public static String getCredentialStoreKeyAlias() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.alias"); - } - - public static String getCredentialStoreKeyStorePassword() throws ApplicationSettingsException { - return getSetting("credential.store.keystore.password"); - } - - public static String getCredentialStoreThriftServerKeyStorePassword() throws ApplicationSettingsException { - return getSetting("credential.store.thrift.server.keystore.password"); - } - - public static String getCredentialStoreServerHost() throws ApplicationSettingsException { - return getSetting("credential.store.server.host"); - } - - public static String getCredentialStoreServerPort() throws ApplicationSettingsException { - return getSetting("credential.store.server.port"); - } - public static String getCredentialStoreNotifierEnabled() throws ApplicationSettingsException { - return getSetting("notifier.enabled"); - } - - public static String getCredentialStoreNotifierDuration() throws ApplicationSettingsException { - return getSetting("notifier.duration"); - } - - public static String getCredentialStoreEmailServer() throws ApplicationSettingsException { - return getSetting("email.server"); - } - - public static String getCredentialStoreEmailServerPort() throws ApplicationSettingsException { - return getSetting("email.server.port"); - } - - public static String getCredentialStoreEmailUser() throws ApplicationSettingsException { - return getSetting("email.user"); - } - - public static String getCredentialStoreEmailPassword() throws ApplicationSettingsException { - return getSetting("email.password"); - } - - public static String getCredentialStoreEmailSSLConnect() throws ApplicationSettingsException { - return getSetting("email.ssl"); - } - - public static String getCredentialStoreEmailFromEmail() throws ApplicationSettingsException { - return getSetting("email.from"); - } - - /** - * @deprecated use {{@link #getSetting(String)}} - * @return - * @throws ApplicationSettingsException - */ - public static Properties getProperties() throws ApplicationSettingsException { - return getInstance().properties; - } - - public static void mergeSettings(Map<String,String> props) { - getInstance().mergeSettingsImpl(props); - } - - public static void mergeSettings(InputStream stream) throws IOException{ - getInstance().mergeSettingsImpl(stream); - } - - public static void mergeSettingsCommandLineArgs(String[] args){ - getInstance().mergeSettingsCommandLineArgsImpl(args); - } - - public static ShutdownStrategy getShutdownStrategy() throws Exception{ - return getInstance().getShutdownStrategyImpl(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java deleted file mode 100644 index 8946aa3..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/BrowserLauncher.java +++ /dev/null @@ -1,98 +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.common.utils; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; - -import org.apache.airavata.common.exception.UtilsException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Opens URLs with the OS-specific browser. - */ -public class BrowserLauncher { - - private static final String ERROR_MESSAGE = "Error while attempting to launch web browser"; - - private static Logger logger = LoggerFactory.getLogger(BrowserLauncher.class); - - /** - * Opens a specified URL with the browser. - * - * @param url - * The specified URL. - * @throws UtilsException - */ - public static void openURL(URL url) throws UtilsException { - openURL(url.toString()); - } - - /** - * Opens a specified URL with the browser. - * - * @param url - * The specified URL. - * @throws UtilsException - */ - public static void openURL(String url) throws UtilsException { - logger.debug("Enter:" + url); - String osName = System.getProperty("os.name"); - try { - if (osName.startsWith("Mac OS")) { - Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils"); - Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] { String.class }); - openURL.invoke(null, new Object[] { url }); - } else if (osName.startsWith("Windows")) - Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); - else { // assume Unix or Linux - String[] browsers = { "firefox", "mozilla", "netscape", "opera", "konqueror" }; - String browser = null; - for (int count = 0; count < browsers.length && browser == null; count++) - if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) - browser = browsers[count]; - if (browser == null) { - throw new UtilsException("Could not find web browser."); - } else { - Runtime.getRuntime().exec(new String[] { browser, url }); - } - } - } catch (ClassNotFoundException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (NoSuchMethodException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (IllegalAccessException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (InvocationTargetException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (IOException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (InterruptedException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } catch (RuntimeException e) { - throw new UtilsException(ERROR_MESSAGE, e); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java deleted file mode 100644 index 5373772..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ClientSettings.java +++ /dev/null @@ -1,27 +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.common.utils; - - -public class ClientSettings extends ApplicationSettings { - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java deleted file mode 100644 index 6855a8e..0000000 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java +++ /dev/null @@ -1,66 +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.common.utils; - -/** - * Constants used in Airavata should go here. - */ -public final class Constants { - - public static final String USER_IN_SESSION = "userName"; -// public static final String GATEWAY_NAME = "gateway_id"; - public static final String GFAC_CONFIG_XML = "gfac-config.xml"; - public static final String PUSH = "push"; - public static final String PULL = "pull"; - public static final String API_SERVER_PORT = "apiserver.server.port"; - public static final String API_SERVER_HOST = "apiserver.server.host"; - public static final String REGISTRY_JDBC_URL = "registry.jdbc.url"; - public static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url"; - public static final String RABBITMQ_BROKER_URL = "rabbitmq.broker.url"; - public static final String RABBITMQ_EXCHANGE = "rabbitmq.exchange.name"; - public static final String ORCHESTRATOR_SERVER_HOST = "orchestrator.server.host"; - public static final String ORCHESTRATOR_SERVER_PORT = "orchestrator.server.port"; - public static final String GFAC_SERVER_HOST = "gfac.server.host"; - public static final String GFAC_SERVER_PORT = "gfac.server.port"; - public static final String CREDENTIAL_SERVER_HOST = "credential.store.server.host"; - public static final String CREDENTIAL_SERVER_PORT = "credential.store.server.port"; - public static final String ZOOKEEPER_EXPERIMENT_CATALOG = "experiment-catalog"; - public static final String ZOOKEEPER_APPCATALOG = "app-catalog"; - public static final String ZOOKEEPER_RABBITMQ = "rabbit-mq"; - public static final String ZOOKEEPER_SERVER_HOST = "zookeeper.server.host"; - public static final String ZOOKEEPER_SERVER_PORT = "zookeeper.server.port"; - public static final String ZOOKEEPER_API_SERVER_NODE = "airavata-server"; - public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NODE = "orchestrator-server"; - public static final String ZOOKEEPER_GFAC_SERVER_NODE = "gfac-server"; - public static final String ZOOKEEPER_GFAC_EXPERIMENT_NODE = "gfac-experiments"; - public static final String ZOOKEEPER_GFAC_SERVER_NAME = "gfac-server-name"; - public static final String ZOOKEEPER_ORCHESTRATOR_SERVER_NAME = "orchestrator-server-name"; - public static final String ZOOKEEPER_API_SERVER_NAME = "api-server-name"; - public static final String STAT = "stat"; - public static final String JOB = "job"; - public static final String ZOOKEEPER_TIMEOUT = "zookeeper.timeout"; - //API security relates property names - public static final String IS_API_SECURED = "api.secured"; - public static final String REMOTE_OAUTH_SERVER_URL = "remote.oauth.authorization.server"; - public static final String ADMIN_USERNAME = "admin.user.name"; - public static final String ADMIN_PASSWORD = "admin.password"; -}
