diff options
Diffstat (limited to 'rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core')
33 files changed, 0 insertions, 4516 deletions
diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOAConfiguration.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOAConfiguration.java deleted file mode 100644 index 4ce372385..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOAConfiguration.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core; - -import java.util.List; - -import org.eclipse.ptp.rm.core.rmsystem.IRemoteResourceManagerConfiguration; -import org.eclipse.ptp.rm.smoa.core.rmsystem.SMOAResourceManager; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOAConnection; - -import com.smoa.comp.stubs.factory.ApplicationsType.Application; - -/** - * Holds values needed by {@link SMOAResourceManager} to operate - that is RM - * configuration and connection options. - * - * Is also informed by {@link SMOAResourceManager} about the available - * applications. - * - * Implemented by {@link SMOAServiceProvider} - */ -public interface SMOAConfiguration extends IRemoteResourceManagerConfiguration { - - /** Authentication mechanisms used to connect to SMOA Computing */ - enum AuthType { - Anonymous, UsernamePassword, GSI - } - - /** Returns application for given name */ - Application getAppForName(String name); - - /** Returns the method of authentication */ - AuthType getAuthType(); - - /** List of predefined applications on the host */ - List<String> getAvailableAppList(); - - /** Path to CA certificate */ - String getCaCertPath(); - - /* If the authentication type needs no <insert name here>, result undefined. */ - - /** For convenience, returns the associated connection */ - SMOAConnection getConnection(); - - /** Returns the password. */ - String getPassword(); - - /** port number for the SMOA computing */ - Integer getPort(); - - /** Service designed name */ - String getServiceDN(); - - /* Managing available applications */ - - /** must return SMOA computing URL - host name */ - String getUrl(); - - /** Returns the user name. */ - String getUser(); - - /** Sets predefined application list */ - void setAvailableAppList(List<Application> apps); -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOACoreActivator.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOACoreActivator.java deleted file mode 100644 index f21100ee6..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOACoreActivator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The plug-in activator. - */ -public class SMOACoreActivator extends Plugin { - - public static final String PLUGIN_ID = "org.eclipse.ptp.rm.smoa.core"; //$NON-NLS-1$ - - private static SMOACoreActivator plugin; - - public static SMOACoreActivator getDefault() { - return plugin; - } - - public SMOACoreActivator() { - plugin = this; - } - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - } - - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOARemoteServicesFactory.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOARemoteServicesFactory.java deleted file mode 100644 index a07a8a0b3..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/SMOARemoteServicesFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core; - -import org.eclipse.ptp.remote.core.IRemoteServices; -import org.eclipse.ptp.remote.core.IRemoteServicesDescriptor; -import org.eclipse.ptp.remote.core.IRemoteServicesFactory; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOARemoteServices; - -/** - * Passed to proper extension point (in plugin.xml) adds - * {@link SMOARemoteServices} to the public list of {@link IRemoteSrvices} - */ -public class SMOARemoteServicesFactory implements IRemoteServicesFactory { - - public static final String ID = SMOARemoteServices.class.getName(); - private SMOARemoteServices services; - - public IRemoteServices getServices(IRemoteServicesDescriptor descriptor) { - - if (services == null) { - services = new SMOARemoteServices(ID, "SMOA Computing"); //$NON-NLS-1$ - } - - return services; - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/Messages.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/Messages.java deleted file mode 100644 index a4138a522..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/Messages.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.ptp.rm.smoa.core.attrib.messages"; //$NON-NLS-1$ - public static String SMOAJobAttributes_0; - public static String SMOAJobAttributes_Application; - public static String SMOAJobAttributes_CustomApplication; - public static String SMOAJobAttributes_CustomMakeCommand; - public static String SMOAJobAttributes_JobDescription; - public static String SMOAJobAttributes_JobNativeSpec; - public static String SMOAJobAttributes_MaxCpus; - public static String SMOAJobAttributes_MinCpus; - public static String SMOAJobAttributes_PreferredMachines; - public static String SMOAJobAttributes_QueueName; - public static String SMOAJobAttributes_RunDirectly; - public static String SMOAJobAttributes_SmoaUUID; - public static String SMOANodeAttributes_CpuArch; - public static String SMOANodeAttributes_CpuCount; - public static String SMOANodeAttributes_PhysicalMemory; - public static String SMOARMAttributes_AcceptsNewActvities; - public static String SMOARMAttributes_CommonName; - public static String SMOARMAttributes_QueueingSystem; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAJobAttributes.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAJobAttributes.java deleted file mode 100644 index 84c89b213..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAJobAttributes.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import java.util.Map; -import java.util.TreeMap; - -import org.eclipse.ptp.core.attributes.ArrayAttributeDefinition; -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.BooleanAttributeDefinition; -import org.eclipse.ptp.core.attributes.IAttributeDefinition; -import org.eclipse.ptp.core.attributes.IntegerAttributeDefinition; -import org.eclipse.ptp.core.attributes.StringAttributeDefinition; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; -import org.eclipse.ptp.core.elements.attributes.JobAttributes; - -/** - * Keeps attributes specific for SMOA Jobs. - * - * Also keeps environmental variables - */ -public class SMOAJobAttributes extends AttributeManager { - - /** Variable name requesting to run 'make' before starting task */ - public static final String ENV_IF_MAKE = "SMOA_COMP_PTP_RUN_MAKE"; //$NON-NLS-1$ - /** Variable name requesting to run 'make' before starting task */ - public static final String ENV_MAKE_COMMAND = "SMOA_COMP_PTP_MAKE_COMMAND"; //$NON-NLS-1$ - /** Environment variable containing file name for stdout */ - public static final String ENV_STDOUT = "SMOA_COMP_PTP_STDOUT"; //$NON-NLS-1$ - /** Environment variable containing file name for stderr */ - public static final String ENV_STDERR = "SMOA_COMP_PTP_STDERR"; //$NON-NLS-1$ - /** Environment variable containing for all processes their node names */ - public static final String ENV_MACHINEFILE = "SMOA_COMP_PTP_MACHINEFILE"; //$NON-NLS-1$ - - /** Text displayed in GUI launch configuration for no wrapper script */ - public static final String NO_WRAPPER_SCRIPT = Messages.SMOAJobAttributes_RunDirectly; - - public final static StringAttributeDefinition getAppNameDef() { - return new StringAttributeDefinition("applicationName", Messages.SMOAJobAttributes_Application, //$NON-NLS-1$ - Messages.SMOAJobAttributes_Application, true, Messages.SMOAJobAttributes_CustomApplication); - } - - public final static StringAttributeDefinition getCustomMakeCommandDef() { - return new StringAttributeDefinition("customMakeCommand", //$NON-NLS-1$ - Messages.SMOAJobAttributes_CustomMakeCommand, Messages.SMOAJobAttributes_CustomMakeCommand, true, null); - } - - public final static StringAttributeDefinition getDescDef() { - return new StringAttributeDefinition("job_desc", Messages.SMOAJobAttributes_JobDescription, //$NON-NLS-1$ - Messages.SMOAJobAttributes_JobDescription, true, ""); //$NON-NLS-1$ - } - - public final static StringMapAttributeDefinition getEnvDef() { - return new StringMapAttributeDefinition("org.eclipse.debug.core.environmentVariables", //$NON-NLS-1$ - "Enviornment vars", "Enviornment vars", false); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public final static BooleanAttributeDefinition getIfCustomMakeDef() { - return new BooleanAttributeDefinition("ifCustomMakeCommand", //$NON-NLS-1$ - "ifCustomMakeCommand", "ifCustomMakeCommand", false, false); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Returns set of possible SMOA Activity attributes. - * - * Used in LaunchConfiguration for filtering attributes. - */ - public static Map<String, IAttributeDefinition<?, ?, ?>> getLaunchAttributes() { - final Map<String, IAttributeDefinition<?, ?, ?>> map = new TreeMap<String, IAttributeDefinition<?, ?, ?>>(); - - putFromDef(map, ElementAttributes.getNameAttributeDefinition()); - - putFromDef(map, JobAttributes.getWorkingDirectoryAttributeDefinition()); - putFromDef(map, JobAttributes.getQueueIdAttributeDefinition()); - - putFromDef(map, JobAttributes.getDebugFlagAttributeDefinition()); - putFromDef(map, JobAttributes.getDebuggerArgumentsAttributeDefinition()); - putFromDef(map, - JobAttributes.getDebuggerExecutableNameAttributeDefinition()); - putFromDef(map, - JobAttributes.getDebuggerExecutablePathAttributeDefinition()); - putFromDef(map, JobAttributes.getDebuggerIdAttributeDefinition()); - putFromDef(map, - JobAttributes.getDebuggerStopInMainFlagAttributeDefinition()); - - putFromDef(map, getMinCpuDef()); - putFromDef(map, getMaxCpuDef()); - putFromDef(map, getDescDef()); - putFromDef(map, getNativeSpecDef()); - putFromDef(map, getPrefferedDef()); - putFromDef(map, getEnvDef()); - putFromDef(map, getAppNameDef()); - putFromDef(map, getMakeDef()); - putFromDef(map, getIfCustomMakeDef()); - putFromDef(map, getCustomMakeCommandDef()); - putFromDef(map, getQueueNameDef()); - - return map; - } - - public final static BooleanAttributeDefinition getMakeDef() { - return new BooleanAttributeDefinition("runMake", Messages.SMOAJobAttributes_0, "runMake", //$NON-NLS-1$ //$NON-NLS-2$ - false, false); - } - - public final static IntegerAttributeDefinition getMaxCpuDef() { - return new IntegerAttributeDefinition("cpu_max", Messages.SMOAJobAttributes_MaxCpus, //$NON-NLS-1$ - Messages.SMOAJobAttributes_MaxCpus, true, 1); - } - - public final static IntegerAttributeDefinition getMinCpuDef() { - return new IntegerAttributeDefinition("cpu_min", Messages.SMOAJobAttributes_MinCpus, //$NON-NLS-1$ - Messages.SMOAJobAttributes_MinCpus, true, 1); - } - - public final static StringAttributeDefinition getNativeSpecDef() { - return new StringAttributeDefinition("job_native_spec", //$NON-NLS-1$ - Messages.SMOAJobAttributes_JobNativeSpec, Messages.SMOAJobAttributes_JobNativeSpec, true, ""); //$NON-NLS-1$ - } - - public final static ArrayAttributeDefinition<String> getPrefferedDef() { - return new ArrayAttributeDefinition<String>("preffered_machines", //$NON-NLS-1$ - Messages.SMOAJobAttributes_PreferredMachines, Messages.SMOAJobAttributes_PreferredMachines, true, new String[0]); - } - - public final static StringAttributeDefinition getQueueNameDef() { - return new StringAttributeDefinition("queue_name", Messages.SMOAJobAttributes_QueueName, //$NON-NLS-1$ - Messages.SMOAJobAttributes_QueueName, true, null); - } - - public final static StringAttributeDefinition getSmoaUuidDef() { - return new StringAttributeDefinition("smoa_uid", Messages.SMOAJobAttributes_SmoaUUID, //$NON-NLS-1$ - Messages.SMOAJobAttributes_SmoaUUID, true, null); - } - - private static void putFromDef( - Map<String, IAttributeDefinition<?, ?, ?>> map, - IAttributeDefinition<?, ?, ?> def) { - map.put(def.getId(), def); - } - - public SMOAJobAttributes() { - addAttribute(JobAttributes.getJobIdAttributeDefinition().create()); - addAttribute(JobAttributes.getStateAttributeDefinition().create()); - addAttribute(JobAttributes.getUserIdAttributeDefinition().create()); - addAttribute(ElementAttributes.getNameAttributeDefinition().create()); - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAMachineAttributes.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAMachineAttributes.java deleted file mode 100644 index a86810e1d..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAMachineAttributes.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.IllegalValueException; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; -import org.eclipse.ptp.core.elements.attributes.MachineAttributes; - -/** - * Keeps attributes specific for SMOA Machines - */ -public class SMOAMachineAttributes extends AttributeManager { - - public SMOAMachineAttributes() { - try { - addAttribute(MachineAttributes.getNumNodesAttributeDefinition() - .create()); - addAttribute(MachineAttributes.getStateAttributeDefinition() - .create(MachineAttributes.State.UP)); - } catch (final IllegalValueException e) { - throw new RuntimeException("This will never hapen", e); //$NON-NLS-1$ - } - addAttribute(ElementAttributes.getNameAttributeDefinition().create()); - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOANodeAttributes.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOANodeAttributes.java deleted file mode 100644 index 9f0d95ff4..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOANodeAttributes.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.IntegerAttributeDefinition; -import org.eclipse.ptp.core.attributes.StringAttributeDefinition; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; - -/** - * Keeps attributes specific for SMOA Node - */ - -public class SMOANodeAttributes extends AttributeManager { - - private static final IntegerAttributeDefinition cpuCount = new IntegerAttributeDefinition( - "cpu_count", Messages.SMOANodeAttributes_CpuCount, Messages.SMOANodeAttributes_CpuCount, true, 1); //$NON-NLS-1$ - - private static final StringAttributeDefinition cpuArch = new StringAttributeDefinition( - "cpu_arch", Messages.SMOANodeAttributes_CpuArch, Messages.SMOANodeAttributes_CpuArch, true, ""); //$NON-NLS-1$ //$NON-NLS-2$ - - private static final StringAttributeDefinition memorySize = new StringAttributeDefinition( - "phys_mem", Messages.SMOANodeAttributes_PhysicalMemory, Messages.SMOANodeAttributes_PhysicalMemory, true, null); //$NON-NLS-1$ - - public static StringAttributeDefinition getCpuArchDef() { - return cpuArch; - } - - public static IntegerAttributeDefinition getCpuCountDef() { - return cpuCount; - } - - public static StringAttributeDefinition getMemorySizeDef() { - return memorySize; - } - - public SMOANodeAttributes() { - addAttribute(ElementAttributes.getNameAttributeDefinition().create()); - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAQueueAttributes.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAQueueAttributes.java deleted file mode 100644 index cfe3034d6..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOAQueueAttributes.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; -import org.eclipse.ptp.core.elements.attributes.QueueAttributes; - -/** - * Keeps attributes specific for SMOA Queues - */ - -public class SMOAQueueAttributes extends AttributeManager { - public SMOAQueueAttributes() { - addAttribute(QueueAttributes.getStateAttributeDefinition().create()); - addAttribute(ElementAttributes.getNameAttributeDefinition().create()); - addAttribute(ElementAttributes.getIdAttributeDefinition().create()); - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOARMAttributes.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOARMAttributes.java deleted file mode 100644 index 95c64f41d..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/SMOARMAttributes.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.BooleanAttributeDefinition; -import org.eclipse.ptp.core.attributes.StringAttributeDefinition; - -/** - * Keeps attributes specific for SMOA ResourceManager - */ - -public class SMOARMAttributes extends AttributeManager { - - static private StringAttributeDefinition queuingSystem = new StringAttributeDefinition( - "queuingSystem", Messages.SMOARMAttributes_QueueingSystem, Messages.SMOARMAttributes_QueueingSystem, true, null); //$NON-NLS-1$ - static private StringAttributeDefinition commonName = new StringAttributeDefinition( - "commonName", Messages.SMOARMAttributes_CommonName, Messages.SMOARMAttributes_CommonName, true, null); //$NON-NLS-1$ - - static private BooleanAttributeDefinition acceptsActivities = new BooleanAttributeDefinition( - "isIsAcceptingNewActivities", Messages.SMOARMAttributes_AcceptsNewActvities, //$NON-NLS-1$ - Messages.SMOARMAttributes_AcceptsNewActvities, true, null); - - static public final BooleanAttributeDefinition getAcceptsActivitiesDef() { - return acceptsActivities; - } - - static public final StringAttributeDefinition getCommonNameDef() { - return commonName; - } - - static public final StringAttributeDefinition getQueuingSystemDef() { - return queuingSystem; - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttribute.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttribute.java deleted file mode 100644 index 4666b1684..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttribute.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.ptp.core.attributes.AbstractAttribute; -import org.eclipse.ptp.core.attributes.IllegalValueException; - -/** - * A {@link AbstractAttribute} that holds string-to-string map. - * - * For the definition, see {@link StringMapAttributeDefinition}. - */ -public class StringMapAttribute - extends - AbstractAttribute<Map<String, String>, StringMapAttribute, StringMapAttributeDefinition> { - - Map<String, String> value = new HashMap<String, String>(); - - public StringMapAttribute( - StringMapAttributeDefinition mapAttributeDefinition, - Map<String, String> value) { - super(mapAttributeDefinition); - - this.value.putAll(value); - } - - public StringMapAttribute( - StringMapAttributeDefinition mapAttributeDefinition, String value) - throws IllegalValueException { - super(mapAttributeDefinition); - setValueAsString(value); - } - - @Override - protected int doCompareTo(StringMapAttribute other) { - return getDefinition().getName().compareToIgnoreCase( - other.getDefinition().getName()); - } - - @Override - protected StringMapAttribute doCopy() { - return new StringMapAttribute(getDefinition(), value); - } - - @Override - protected boolean doEquals(StringMapAttribute other) { - return value.equals(other.value); - } - - @Override - protected int doHashCode() { - return value.hashCode(); - } - - public Map<String, String> getValue() { - return Collections.unmodifiableMap(value); - } - - public String getValueAsString() { - final StringBuilder result = new StringBuilder(); - for (final Entry<String, String> element : value.entrySet()) { - result.append(element.getKey().replaceAll(" = ", " \\= ") //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll(" ; ", " \\; ")); //$NON-NLS-1$ //$NON-NLS-2$ - result.append(" = "); //$NON-NLS-1$ - result.append(element.getValue().replaceAll(" ; ", " \\; ")); //$NON-NLS-1$ //$NON-NLS-2$ - result.append(" ; "); //$NON-NLS-1$ - } - result.delete(result.length() - 3, result.length() - 1); - return result.toString(); - } - - public boolean isValid(String string) { - final String[] pairs = string.split(" ; "); //$NON-NLS-1$ - for (final String pair : pairs) { - final String[] keyVal = pair.split(" = ", 2); //$NON-NLS-1$ - if (keyVal.length != 2) { - return false; - } - } - return true; - } - - public void setValue(Map<String, String> value) - throws IllegalValueException { - this.value.clear(); - this.value.putAll(value); - - } - - public void setValueAsString(String string) throws IllegalValueException { - final Map<String, String> newVal = new HashMap<String, String>(); - - final String[] pairs = string.split(" ; "); //$NON-NLS-1$ - - for (final String pair : pairs) { - final String[] keyVal = pair.replaceAll(" \\; ", " ; ").split(" = ", 2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (keyVal.length != 2) { - throw new IllegalValueException("Bad format"); //$NON-NLS-1$ - } - newVal.put(keyVal[0].replaceAll(" \\= ", " = "), keyVal[1]); //$NON-NLS-1$ //$NON-NLS-2$ - } - - value = newVal; - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttributeDefinition.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttributeDefinition.java deleted file mode 100644 index dbcd3bd8a..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/StringMapAttributeDefinition.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.attrib; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ptp.core.attributes.AbstractAttributeDefinition; -import org.eclipse.ptp.core.attributes.IllegalValueException; - -/** - * A {@link AbstractAttributeDefinition} for storing a string-to-string map. - * - * The attribute is called {@link StringMapAttribute}. - */ - -public class StringMapAttributeDefinition - extends - AbstractAttributeDefinition<Map<String, String>, StringMapAttribute, StringMapAttributeDefinition> { - - private final Map<String, String> defaultValue; - - public StringMapAttributeDefinition(String uniqueId, String name, - String description, boolean display) { - this(uniqueId, name, description, display, - new HashMap<String, String>()); - } - - public StringMapAttributeDefinition(String uniqueId, String name, - String description, boolean display, - final Map<String, String> defaultValue) { - super(uniqueId, name, description, display); - this.defaultValue = defaultValue; - } - - public StringMapAttribute create() throws IllegalValueException { - return new StringMapAttribute(this, defaultValue); - } - - public StringMapAttribute create(Map<String, String> value) - throws IllegalValueException { - return new StringMapAttribute(this, value); - } - - public StringMapAttribute create(String value) throws IllegalValueException { - return new StringMapAttribute(this, value); - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/messages.properties b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/messages.properties deleted file mode 100644 index cc8c9c369..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/attrib/messages.properties +++ /dev/null @@ -1,18 +0,0 @@ -SMOAJobAttributes_0=runMake -SMOAJobAttributes_Application=Application -SMOAJobAttributes_CustomApplication=Custom -SMOAJobAttributes_CustomMakeCommand=Custom make command -SMOAJobAttributes_JobDescription=Job description -SMOAJobAttributes_JobNativeSpec=Job native specification -SMOAJobAttributes_MaxCpus=Max CPU-s -SMOAJobAttributes_MinCpus=Min CPU-s -SMOAJobAttributes_PreferredMachines=Preffered machines -SMOAJobAttributes_QueueName=Queue name -SMOAJobAttributes_RunDirectly=Run directly -SMOAJobAttributes_SmoaUUID=SMOA Comp Job UUID -SMOANodeAttributes_CpuArch=CPU architecture -SMOANodeAttributes_CpuCount=CPU count -SMOANodeAttributes_PhysicalMemory=Physical Memory -SMOARMAttributes_AcceptsNewActvities=Accepts new activities -SMOARMAttributes_CommonName=Common name -SMOARMAttributes_QueueingSystem=Queuing System diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/JobThread.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/JobThread.java deleted file mode 100644 index 95ce6ca9b..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/JobThread.java +++ /dev/null @@ -1,442 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.BitSet; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.elements.IPJob; -import org.eclipse.ptp.core.elements.IPMachine; -import org.eclipse.ptp.core.elements.IPNode; -import org.eclipse.ptp.core.elements.IPResourceManager; -import org.eclipse.ptp.core.elements.attributes.JobAttributes; -import org.eclipse.ptp.core.elements.attributes.ProcessAttributes; -import org.eclipse.ptp.remote.core.IRemoteFileManager; -import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; -import org.eclipse.ptp.rm.smoa.core.rmsystem.PoolingIntervalsAndStatic.SMOAJobState; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOAFileStore; -import org.eclipse.ptp.rm.smoa.core.util.NotifyShell; - -import com.smoa.comp.sdk.SMOAFactory; -import com.smoa.comp.sdk.exceptions.FileNotFoundException; -import com.smoa.comp.sdk.exceptions.NotAuthorizedException; -import com.smoa.comp.sdk.exceptions.UnknownActivityIdentifierException; -import com.smoa.comp.sdk.types.ActivityEndpointReference; -import com.smoa.comp.sdk.types.SMOAActivityStatus; - -/** - * Thread for monitoring a single job - checks state and transfers standard - * output. Allows job's termination. - */ -class JobThread extends Thread { - // The RM that created the job - private final SMOAResourceManager rm; - private final IPResourceManager pRM; - - // The eclipse job control object - private final IPJob jobControl; - - // The SMOA job control object - private final ActivityEndpointReference activityIdentifier; - - private final SMOAFactory factory; - private final IRemoteFileManager fileManager; - - // Remote files used by launch - private final IFileStore out; - private final IFileStore err; - private final IFileStore sh; - private final IFileStore machinefile; - - // Offsets for the output files - private int stdOutOffset = 0; - private int stdErrOffset = 0; - - /** - * Constructs the job thread for monitoring a single job - */ - public JobThread(SMOAResourceManager rm, SMOAFactory factory, ActivityEndpointReference activityEndpointReference, - IPJob jobControl, String out, String err, String sh, String machinefile) { - this.rm = rm; - this.pRM = (IPResourceManager) rm.getAdapter(IPResourceManager.class); - this.factory = factory; - this.activityIdentifier = activityEndpointReference; - this.jobControl = jobControl; - - this.setPriority(MIN_PRIORITY); - this.setName("JobListener for " + activityIdentifier.getActivityUUID()); //$NON-NLS-1$ - - final IRemoteFileManager fileManager_t = PTPRemoteCorePlugin.getDefault() - .getRemoteServices(rm.getControlConfiguration().getRemoteServicesId()) - .getFileManager(rm.getControlConfiguration().getConnection()); - - fileManager = fileManager_t; - - this.out = fileManager.getResource(out); - this.err = fileManager.getResource(err); - if (sh != null) { - this.sh = fileManager.getResource(sh); - } else { - this.sh = null; - } - if (machinefile != null) { - this.machinefile = fileManager.getResource(machinefile); - } else { - this.machinefile = null; - } - - } - - /** Adds given text to standard error, and makes it appear on console */ - void appendStdErr(String stderr) { - final AttributeManager outManager = new AttributeManager(); - outManager.addAttribute(ProcessAttributes.getStderrAttributeDefinition().create(stderr)); - final BitSet bs = new BitSet(); - bs.set(jobControl.getProcessJobRanks().nextSetBit(0)); - jobControl.addProcessAttributes(bs, outManager); - } - - /** Adds given text to standard output, and makes it appear on console */ - void appendStdOut(String stdout) { - final AttributeManager outManager = new AttributeManager(); - outManager.addAttribute(ProcessAttributes.getStdoutAttributeDefinition().create(stdout)); - final BitSet bs = new BitSet(); - bs.set(jobControl.getProcessJobRanks().nextSetBit(0)); - jobControl.addProcessAttributes(bs, outManager); - } - - /** - * Changes job state - */ - void changeState(JobAttributes.State newState) { - if (JobAttributes.State.RUNNING.equals(newState)) { - enteredRunPhase(); - } - - final AttributeManager am = new AttributeManager(); - am.addAttribute(JobAttributes.getStateAttributeDefinition().create(newState)); - rm.getMonitor().getRuntimeSystem().changeJob(jobControl.getID(), am); - } - - /** - * Called when the process state becomes RUNNING. - * - * This is the proper moment for identifying where the processes are - * located, so that debug routing files may be written. - */ - private void enteredRunPhase() { - if (machinefile != null) { - try { - final BufferedReader reader = new BufferedReader(new InputStreamReader(machinefile.openInputStream(0, null))); - - final IPMachine machine = pRM.getMachines()[0]; - - final Map<String, String> nodesByName = new HashMap<String, String>(); - for (final IPNode ipNode : machine.getNodes()) { - nodesByName.put(ipNode.getName(), ipNode.getID()); - } - - String line; - int i = 0; - while ((line = reader.readLine()) != null) { - final BitSet bs = new BitSet(); - bs.set(i++); - final AttributeManager attrs = new AttributeManager(); - - if (!nodesByName.containsKey(line)) { - rm.getMonitor().getRuntimeSystem().addUnknownNode(machine, line); - nodesByName.put(line, ((Integer) nodesByName.size()).toString()); - NotifyShell.open(Messages.JobThread_UnknownNode_title, Messages.JobThread_UnknownNode_text_1 + line - + Messages.JobThread_UnknownNode_text_2); - attrs.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create(nodesByName.get(line))); - } else { - attrs.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create(nodesByName.get(line))); - } - jobControl.addProcessesByJobRanks(bs, attrs); - } - return; - } catch (final CoreException e) { - NotifyShell.open(Messages.JobThread_ErrorOpeningRemote, e.toString()); - - final BitSet bs = new BitSet(1); - bs.set(0); - final AttributeManager jam = new AttributeManager(); - jam.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create("0")); //$NON-NLS-1$ - jobControl.addProcessesByJobRanks(bs, jam); - } catch (final IOException e) { - NotifyShell.open(Messages.JobThread_ErrorReadingRemote, e.toString()); - - if (jobControl.getProcessJobRanks() != null && !jobControl.getProcessJobRanks().isEmpty()) { - return; - } - - final BitSet bs = new BitSet(1); - bs.set(0); - final AttributeManager jam = new AttributeManager(); - jam.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create("0")); //$NON-NLS-1$ - jobControl.addProcessesByJobRanks(bs, jam); - } - } else { - final BitSet bs = new BitSet(1); - bs.set(0); - final AttributeManager jam = new AttributeManager(); - jam.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create("0")); //$NON-NLS-1$ - jobControl.addProcessesByJobRanks(bs, jam); - } - } - - /** - * Called if an exception has been thrown while monitoring job - */ - void exceptionCaught(Exception e) { - final AttributeManager am = new AttributeManager(); - - am.addAttribute(JobAttributes.getStatusAttributeDefinition().create(Messages.JobThread_ExceptionByMonitoring)); - - am.addAttribute(JobAttributes.getStateAttributeDefinition().create(JobAttributes.State.COMPLETED)); - - am.addAttribute(PoolingIntervalsAndStatic.exceptionAttrDef.create(e.getLocalizedMessage())); - - NotifyShell.open(Messages.JobThread_ExceptionByMonitoring, e.getLocalizedMessage()); - - rm.getMonitor().getRuntimeSystem().changeJob(jobControl.getID(), am); - } - - /** Executed after the job reached terminal state */ - private void jobFinished(SMOAActivityStatus status) { - - try { - // If the job jumped from queued to finished state, we didn't - // add any processes yet - if (jobControl.getProcessJobRanks() == null || jobControl.getProcessJobRanks().isEmpty()) { - final BitSet bs = new BitSet(1); - bs.set(0); - final AttributeManager jam = new AttributeManager(); - jam.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create("0")); //$NON-NLS-1$ - jobControl.addProcessesByJobRanks(bs, jam); - } - - processOutAndErr(); - - try { - out.delete(0, null); - err.delete(0, null); - if (sh != null) { - sh.delete(0, null); - } - if (machinefile != null) { - machinefile.delete(0, null); - } - } catch (final CoreException e) { - NotifyShell.open(Messages.JobThread_ErrorDeletingTempFiles_title, Messages.JobThread_ErrorDeletingTempFiles_text - + e.getLocalizedMessage()); - e.printStackTrace(); - } - } catch (final RuntimeException e) { - // Happens if there is a problem with stdout/err file - } - - final AttributeManager am = new AttributeManager(); - - String jobStatus = null; - - switch (PoolingIntervalsAndStatic.getEquivalentJobState(status)) { - case Finished: - jobStatus = Messages.JobThread_JobStateFinisedWithStatus + status.getEndStatus().getExitStatus(); - break; - case Failed: - jobStatus = Messages.JobThread_JobStateFailed; - break; - case Cancelled: - jobStatus = Messages.JobThread_JobStateCancelled; - break; - default: - jobStatus = Messages.JobThread_JobStateUnknown; - } - - am.addAttribute(JobAttributes.getStatusAttributeDefinition().create(jobStatus)); - - JobAttributes.State state; - state = JobAttributes.State.COMPLETED; - am.addAttribute(JobAttributes.getStateAttributeDefinition().create(state)); - - rm.getMonitor().getRuntimeSystem().changeJob(jobControl.getID(), am); - } - - /** - * Takes care about reading out and err streams and forwards them on console - */ - private void processOutAndErr() { - - /* Out */ - InputStream is; - try { - if (out instanceof SMOAFileStore) { - is = ((SMOAFileStore) out).openInputStream(0, null, stdOutOffset); - } else { - is = out.openInputStream(0, null); - is.skip(stdOutOffset); - } - - final byte[] buffer = new byte[512]; - - for (int count = is.read(buffer); count > 0; count = is.read(buffer)) { - stdOutOffset += count; - appendStdOut(new String(buffer).substring(0, count)); - } - } catch (final CoreException e) { - if (e.getCause() instanceof FileNotFoundException) { - return; - } - throw new RuntimeException(e); - } catch (final IOException e) { - NotifyShell.open(Messages.JobThread_ErrorOut, e.getLocalizedMessage()); - } - - /* Err */ - - try { - if (err instanceof SMOAFileStore) { - is = ((SMOAFileStore) err).openInputStream(0, null, stdErrOffset); - } else { - is = err.openInputStream(0, null); - is.skip(stdErrOffset); - } - - final byte[] buffer = new byte[512]; - - for (int count = is.read(buffer); count > 0; count = is.read(buffer)) { - stdErrOffset += count; - if (count == buffer.length) { - appendStdErr(new String(buffer)); - } else { - appendStdErr(new String(buffer).substring(0, count)); - } - } - } catch (final CoreException e) { - if (e.getCause() instanceof FileNotFoundException) { - return; - } - throw new RuntimeException(e); - } catch (final IOException e) { - NotifyShell.open(Messages.JobThread_ErrorErr, e.getLocalizedMessage()); - } - } - - /** Loop for monitoring task */ - @Override - public void run() { - try { - - SMOAActivityStatus status = factory.getActivityStatus(activityIdentifier); - - SMOAActivityStatus prevStatus = null; - - long nextStateCheck = System.currentTimeMillis(); - long nextOutCheck = nextStateCheck; - - // Till the state is not final, we pool the job and out streams - while (true) { - - // Status - if (nextStateCheck <= System.currentTimeMillis()) { - nextStateCheck = System.currentTimeMillis() + PoolingIntervalsAndStatic.getPoolingIntervalTask(); - - final SMOAJobState statusS = PoolingIntervalsAndStatic.getEquivalentJobState(status); - - SMOAJobState prevstatusS = null; - - if (prevStatus != null) { - prevstatusS = PoolingIntervalsAndStatic.getEquivalentJobState(prevStatus); - } - - if (prevStatus == null || !statusS.equals(prevstatusS)) { - switch (statusS) { - case Stage_in: - case Held: - case Queued: - changeState(JobAttributes.State.STARTING); - break; - case Stage_out: - case Executing: - changeState(JobAttributes.State.RUNNING); - break; - case Suspended: - changeState(JobAttributes.State.SUSPENDED); - break; - - case Cancelled: - break; - case Failed: - break; - case Finished: - break; - } - prevStatus = status; - } - status = factory.getActivityStatus(activityIdentifier); - - if (status.isFinalState()) { - break; - } - } - - // Out - final JobAttributes.State state = jobControl.getAttribute(JobAttributes.getStateAttributeDefinition()).getValue(); - if (state == JobAttributes.State.RUNNING && nextOutCheck <= System.currentTimeMillis()) { - nextOutCheck = System.currentTimeMillis() + PoolingIntervalsAndStatic.getPoolingIntervalOut(); - - processOutAndErr(); - } - try { - final long nextCheck = Math.min(nextOutCheck - System.currentTimeMillis(), - nextStateCheck - System.currentTimeMillis()); - if (nextCheck > 0) { - sleep(nextCheck); - } - } catch (final InterruptedException e) { - // The job has been terminated, ignore - } - } - - jobFinished(status); - - } catch (final NotAuthorizedException e) { - exceptionCaught(e); - } catch (final UnknownActivityIdentifierException e) { - exceptionCaught(e); - } - - rm.removeJobThread(jobControl.getID()); - } - - /** - * Terminates the monitored job - */ - public boolean terminate() { - try { - factory.terminateActivity(activityIdentifier); - this.interrupt(); - } catch (final Exception e) { - return false; - } - return true; - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/Messages.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/Messages.java deleted file mode 100644 index b4e7b88e6..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/Messages.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.ptp.rm.smoa.core.rmsystem.messages"; //$NON-NLS-1$ - public static String JobThread_ErrorDeletingTempFiles_text; - public static String JobThread_ErrorDeletingTempFiles_title; - public static String JobThread_ErrorErr; - public static String JobThread_ErrorOpeningRemote; - public static String JobThread_ErrorOut; - public static String JobThread_ErrorReadingRemote; - public static String JobThread_ExceptionByMonitoring; - public static String JobThread_JobStateCancelled; - public static String JobThread_JobStateFailed; - public static String JobThread_JobStateFinisedWithStatus; - public static String JobThread_JobStateUnknown; - public static String JobThread_UnknownNode_text_1; - public static String JobThread_UnknownNode_text_2; - public static String JobThread_UnknownNode_title; - public static String PoolingIntervalsAndStatic_JobSubmissionFailed; - public static String SMOAResourceManager_7; - public static String SMOAResourceManager_8; - public static String SMOAResourceManager_JobSubmissionFailed; - public static String SMOAResourceManager_PortForwardingFailed_text; - public static String SMOAResourceManager_PortForwardingFailed_title; - public static String SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_text; - public static String SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_title; - public static String SMOAResourceManagerConfiguration_CouldNotRetreivePassword; - public static String SMOAResourceManagerConfiguration_CouldNotStorePassword; - public static String SMOAResourceManagerConfiguration_PrefixAnonymous; - public static String SMOAResourceManagerConfiguration_PrefixGsi; - public static String SMOAResourceManagerConfiguration_ReusingConnection; - public static String SMOAResourceManagerConfiguration_SmoaRmDescription; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervals.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervals.java deleted file mode 100644 index 367c747b8..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervals.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -/** - * Static class holding information about pooling intervals of task and output - * status. - */ - -/* - * When this functionality has been part of SMOAResourceManager class, a - * ClassCircularityExcepthion has been thrown under certain circumstances. - */ -public class PoolingIntervals { - - /** Default interval for checking job state. */ - public static final int DEFAULT_POOLING_STATE = 10000; - /** Default interval for checking job out and err state. */ - public static final int DEFAULT_POOLING_OUT = 15000; - - /** Interval for checking job state. Global for all jobs. */ - private static int PoolingIntervalState = DEFAULT_POOLING_STATE; - /** Interval for checking job out and err state. Global for all jobs. */ - private static int PoolingIntervalOut = DEFAULT_POOLING_OUT; - - /** Retrieves value of the output checking interval */ - public static int getPoolingIntervalOut() { - return PoolingIntervalOut; - } - - /** Retrieves value of the job state checking interval */ - public static int getPoolingIntervalTask() { - return PoolingIntervalState; - } - - /** How often the output will be checked (but not less than 0.1s) */ - public static void setPoolingIntervalOut(int newVal) { - if (newVal >= 100) { - PoolingIntervalOut = newVal; - } - } - - /** How often the job state will be checked (but not less than 0.1s) */ - public static void setPoolingIntervalTask(int newVal) { - if (newVal >= 100) { - PoolingIntervalState = newVal; - } - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervalsAndStatic.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervalsAndStatic.java deleted file mode 100644 index 7bf20cbd1..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/PoolingIntervalsAndStatic.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ptp.core.attributes.StringAttributeDefinition; - -import com.smoa.comp.sdk.types.SMOAActivityStatus; - -/** - * Static class holding information about pooling intervals of task and output - * status. - * - * This class also holds some static methods i order to make - * {@link SMOAResourceManager} thinner. - */ - -/* - * When this functionality has been part of SMOAResourceManager class, a - * ClassCircularityExcepthion has been thrown under certain circumstances. - */ -public class PoolingIntervalsAndStatic { - - /** All possible states returned by getBESState and getBESSubState */ - public static enum SMOAJobState { - Cancelled, Finished, Failed, Executing, Stage_in, Stage_out, Queued, Held, Suspended - } - - /** Default interval for checking job state. */ - public static final int DEFAULT_POOLING_STATE = 10000; - - /** Default interval for checking job out and err state. */ - public static final int DEFAULT_POOLING_OUT = 15000; - /** Interval for checking job state. Global for all jobs. */ - private static int PoolingIntervalState = DEFAULT_POOLING_STATE; - - /** Interval for checking job out and err state. Global for all jobs. */ - private static int PoolingIntervalOut = DEFAULT_POOLING_OUT; - - /** Definition of a attribute holding error message */ - public static StringAttributeDefinition exceptionAttrDef = new StringAttributeDefinition( - "exception", Messages.PoolingIntervalsAndStatic_JobSubmissionFailed, Messages.PoolingIntervalsAndStatic_JobSubmissionFailed, //$NON-NLS-1$ - true, ""); //$NON-NLS-1$ - - private static final Map<String, SMOAJobState> besStateNameToEnum = new HashMap<String, SMOAJobState>(); - - private static final Map<String, SMOAJobState> besSubStateNameToEnum = new HashMap<String, SMOAJobState>(); - - static { - besStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_CANCELLED, - SMOAJobState.Cancelled); - besStateNameToEnum.put(SMOAActivityStatus.SMOA_ACTIVITY_STATE_FAILED, - SMOAJobState.Failed); - besStateNameToEnum.put(SMOAActivityStatus.SMOA_ACTIVITY_STATE_FINISHED, - SMOAJobState.Finished); - } - - static { - besSubStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_EXECUTING, - SMOAJobState.Executing); - besSubStateNameToEnum.put(SMOAActivityStatus.SMOA_ACTIVITY_STATE_HELD, - SMOAJobState.Held); - besSubStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_QUEUED, - SMOAJobState.Queued); - besSubStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_STAGE_IN, - SMOAJobState.Stage_in); - besSubStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_STAGE_OUT, - SMOAJobState.Stage_out); - besSubStateNameToEnum.put( - SMOAActivityStatus.SMOA_ACTIVITY_STATE_SUSPENDED, - SMOAJobState.Suspended); - } - - /** Maps BES state name to SMOA JobState */ - public static SMOAJobState getEquivalentJobState(SMOAActivityStatus status) { - final SMOAJobState result = besStateNameToEnum.get(status.getBESStateName()); - if (result != null) { - return result; - } - return besSubStateNameToEnum.get(status.getBESSubStateName()); - } - - /** Retrieves value of the output checking interval */ - public static int getPoolingIntervalOut() { - return PoolingIntervalOut; - } - - /** Retrieves value of the job state checking interval */ - public static int getPoolingIntervalTask() { - return PoolingIntervalState; - } - - /** How often the output will be checked (but not less than 0.1s) */ - public static void setPoolingIntervalOut(int newVal) { - if (newVal >= 100) { - PoolingIntervalOut = newVal; - } - } - - /** How often the job state will be checked (but not less than 0.1s) */ - public static void setPoolingIntervalTask(int newVal) { - if (newVal >= 100) { - PoolingIntervalState = newVal; - } - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManager.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManager.java deleted file mode 100644 index c60c94283..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManager.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ptp.rtsystem.AbstractRuntimeResourceManager; - -public class SMOAResourceManager extends AbstractRuntimeResourceManager { - - /** - * Holds JobThread for each running job (identified by JobID), so that RM - * can inform JobThread to terminate the job - */ - private final Map<String, JobThread> jobThreadForID = new HashMap<String, JobThread>(); - - public SMOAResourceManager(SMOAResourceManagerConfiguration config, SMOAResourceManagerControl control, - SMOAResourceManagerMonitor monitor) { - super(config, control, monitor); - } - - @Override - public SMOAResourceManagerControl getControl() { - return (SMOAResourceManagerControl) super.getControl(); - } - - @Override - public SMOAResourceManagerConfiguration getControlConfiguration() { - return (SMOAResourceManagerConfiguration) super.getControlConfiguration(); - } - - @Override - public SMOAResourceManagerMonitor getMonitor() { - return (SMOAResourceManagerMonitor) super.getMonitor(); - } - - @Override - public SMOAResourceManagerConfiguration getMonitorConfiguration() { - return (SMOAResourceManagerConfiguration) super.getMonitorConfiguration(); - } - - protected void addJobThread(String jobId, JobThread job) { - jobThreadForID.put(jobId, job); - } - - protected JobThread getJobThread(String jobId) { - return jobThreadForID.get(jobId); - } - - protected void removeJobThread(String jobId) { - jobThreadForID.remove(jobId); - } - -}
\ No newline at end of file diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerConfiguration.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerConfiguration.java deleted file mode 100644 index b2576e0c7..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerConfiguration.java +++ /dev/null @@ -1,412 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.equinox.security.storage.ISecurePreferences; -import org.eclipse.equinox.security.storage.SecurePreferencesFactory; -import org.eclipse.equinox.security.storage.StorageException; -import org.eclipse.ptp.remote.core.IRemoteConnection; -import org.eclipse.ptp.remote.core.IRemoteServices; -import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; -import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; -import org.eclipse.ptp.rm.core.rmsystem.AbstractRemoteResourceManagerConfiguration; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOAConnection; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOARemoteServices; -import org.eclipse.ptp.rm.smoa.core.util.NotifyShell; -import org.eclipse.ptp.services.core.IServiceProvider; - -import com.smoa.comp.stubs.factory.ApplicationsType.Application; - -/** - * Persistently keeps data about one {@link SMOAResourceManager} configuration, - * i.e. connection data, authentication methods - * - * Keeps also other things related to the RM, like available applications or the - * connection - */ -public class SMOAResourceManagerConfiguration extends AbstractRemoteResourceManagerConfiguration implements SMOAConfiguration { - - // Keys used for storing persistent data - private final static String URL_KEY = "url"; //$NON-NLS-1$ - private final static String PORT_KEY = "port"; //$NON-NLS-1$ - private static final String AUTH_KEY = "auth"; //$NON-NLS-1$ - private static final String USER_KEY = "user"; //$NON-NLS-1$ - private static final String CACERT_KEY = "cacert"; //$NON-NLS-1$ - private static final String DN_KEY = "dn"; //$NON-NLS-1$ - private static final String RS_ID_KEY = "rs_id"; //$NON-NLS-1$ - - private static final String RS_CONN_KEY = "rs_conn"; //$NON-NLS-1$ - - // Place for passwords - ISecurePreferences securePrefs = SecurePreferencesFactory.getDefault().node("smoa"); //$NON-NLS-1$ - // Made to differentiate connections with same name, but different data - private static int nextConnectionId = 0; - - private static Object nextConnectionIdLock = new Object(); - private boolean isConectionInitialized = false; - private SMOAConnection connection = null; - private final SMOAResourceManager resourceManager = null; - - private Map<String, Application> apps; - - boolean notifiedAboutConnLoss = true; - - public SMOAResourceManagerConfiguration() { - super(); - } - - protected SMOAResourceManagerConfiguration(String namespace, IServiceProvider provider) { - super(namespace, provider); - setDescription(Messages.SMOAResourceManagerConfiguration_SmoaRmDescription); - setRemoteServicesId("org.eclipse.ptp.remote.SMOARemoteServices"); //$NON-NLS-1$ - } - - public Application getAppForName(String name) { - if (apps == null) { - return null; - } - return apps.get(name); - } - - public AuthType getAuthType() { - final String auth = getString(AUTH_KEY, AuthType.Anonymous.toString()); - return AuthType.valueOf(auth); - } - - // SettersAndGetters - - public List<String> getAvailableAppList() { - final Vector<String> _ = new Vector<String>(); - if (apps != null) { - _.addAll(apps.keySet()); - } - return _; - } - - public String getCaCertPath() { - return getString(CACERT_KEY, null); - } - - public SMOAConnection getConnection() { - return connection; - } - - @Override - public String getConnectionName() { - if (!isConectionInitialized) { - initConnection(); - } - return super.getConnectionName(); - } - - public IRemoteConnection getFileRemoteConnection() { - IRemoteConnection fileRemoteConnection = null; - final String id = getString(RS_ID_KEY, null); - final String name = getString(RS_CONN_KEY, null); - if (id != null && name != null) { - final IRemoteServices rs = PTPRemoteCorePlugin.getDefault().getRemoteServices(id); - if (rs != null) { - fileRemoteConnection = rs.getConnectionManager().getConnection(name); - } - - if (fileRemoteConnection == null) { - notifyConnLoss(); - } - } - return fileRemoteConnection; - } - - public String getPassword() { - if (getUrl() == null) { - return null; - } - String pass = null; - try { - pass = securePrefs.get(getUrl(), null); - } catch (final StorageException e) { - Logger.getLogger(getClass().getCanonicalName()).log(Level.SEVERE, - Messages.SMOAResourceManagerConfiguration_CouldNotRetreivePassword, e); - } - return pass; - } - - public Integer getPort() { - final int port = getInt(PORT_KEY, -1); - return port == -1 ? null : port; - } - - @Override - public String getResourceManagerId() { - return getId(); - } - - public String getServiceDN() { - return getString(DN_KEY, null); - } - - public String getUrl() { - return getString(URL_KEY, null); - } - - public String getUser() { - return getString(USER_KEY, null); - } - - /** - * Creates a connection in the SMOAConnectionManager - */ - private void initConnection() { - - final SMOARemoteServices remoteServices = (SMOARemoteServices) PTPRemoteCorePlugin.getDefault().getRemoteServices( - getRemoteServicesId()); - - final IRemoteConnection existingConnection = remoteServices.getConnectionManager().getConnection(super.getConnectionName()); - if (existingConnection != null) { - connection = (SMOAConnection) existingConnection; - Logger.getLogger(getClass().getName()).info(Messages.SMOAResourceManagerConfiguration_ReusingConnection); - return; - } - - try { - final SMOAConnection c = remoteServices.getConnectionManager().newConnection(super.getConnectionName()); - c.setAddress(getUrl()); - c.setFileConnection(getFileRemoteConnection()); - c.setRMName(this.getName()); - - if (getAuthType() == AuthType.UsernamePassword) { - c.setUsername(getUser()); - c.setPassword(getPassword()); - } - - c.setPort(getPort()); - c.setAuthType(getAuthType()); - - if (getCaCertPath() != null && !getCaCertPath().isEmpty()) { - c.setCaCert(getCaCertPath()); - if (getServiceDN() != null && !getServiceDN().isEmpty()) { - c.setDN(getServiceDN()); - } - } - connection = c; - } catch (final RemoteConnectionException e) { - // should never happen - throw new RuntimeException(e); - } - - isConectionInitialized = true; - } - - @Override - public boolean isConfigured() { - return true; - } - - @Override - public boolean needsDebuggerLaunchHelp() { - return true; - } - - private void notifyConnLoss() { - if (notifiedAboutConnLoss) { - notifiedAboutConnLoss = false; - NotifyShell.open(Messages.SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_title, - Messages.SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_text); - } - } - - public void setAuthType(AuthType type) { - putString(AUTH_KEY, type.toString()); - } - - public void setAvailableAppList(List<Application> appList) { - apps = new HashMap<String, Application>(); - for (final Application a : appList) { - final String version = a.getVersion() == null ? "" : (" " + a //$NON-NLS-1$ //$NON-NLS-2$ - .getVersion()); - apps.put(a.getName() + version, a); - } - } - - public void setCacertPath(String cacert) { - if (cacert == null) { - return; - } - if (cacert.equals(getCaCertPath())) { - return; - } - putString(CACERT_KEY, cacert); - - updateConnectionName(); - } - - public void setDefaultNameAndDesc() { - - final StringBuilder name = new StringBuilder("SMOA Comp"); //$NON-NLS-1$ - if (getUrl() != null) { - name.append(" - "); //$NON-NLS-1$ - - switch (getAuthType()) { - case Anonymous: - name.append(Messages.SMOAResourceManagerConfiguration_PrefixAnonymous); - break; - case GSI: - name.append(Messages.SMOAResourceManagerConfiguration_PrefixGsi); - break; - case UsernamePassword: - if (getUser() != null) { - name.append(getUser()); - } - name.append("@"); //$NON-NLS-1$ - break; - } - - if (getUrl() != null) { - name.append(getUrl()); - } - name.append(":"); //$NON-NLS-1$ - if (getPort() != null) { - name.append(getPort()); - } - } - - setName(name.toString()); - - setDescription("SMOA Computing Resource Manager"); //$NON-NLS-1$ - } - - public void setFileRemoteConnection(IRemoteConnection rconn) { - if (rconn != null) { - putString(RS_ID_KEY, rconn.getRemoteServices().getId()); - putString(RS_CONN_KEY, rconn.getName()); - } else { - putString(RS_ID_KEY, null); - putString(RS_CONN_KEY, null); - } - } - - @Override - public void setName(String name) { - if (connection != null) { - connection.setRMName(name); - } - super.setName(name); - } - - public void setPassword(String passwd) { - if (passwd == null) { - return; - } - if (passwd.equals(getPassword())) { - return; - } - if (getUrl() == null) { - return; - } - - try { - securePrefs.put(getUrl(), passwd, true); - } catch (final StorageException e) { - Logger.getLogger(getClass().getCanonicalName()).log(Level.SEVERE, - Messages.SMOAResourceManagerConfiguration_CouldNotStorePassword, e); - } - - updateConnectionName(); - } - - public void setPort(Integer port) { - if (port == getPort()) { - return; - } - putInt(PORT_KEY, port); - updateConnectionName(); - } - - public void setServiceDn(String dn) { - if (dn == null) { - return; - } - if (dn.equals(getServiceDN())) { - return; - } - putString(DN_KEY, dn); - - updateConnectionName(); - } - - public void setUrl(String url) { - if (url.equals(getUrl())) { - return; - } - - final String pass = getPassword(); - if (getUrl() != null) { - securePrefs.remove(getUrl()); - } - - putString(URL_KEY, url); - - if (pass == null) { - setPassword(pass); - } - - updateConnectionName(); - } - - public void setUser(String user) { - if (user == null) { - return; - } - if (user.equals(getUser())) { - return; - } - putString(USER_KEY, user); - - updateConnectionName(); - } - - public void trigerSecureStorage() throws StorageException { - // Just do something in order to force asking for password - securePrefs.put("How should I init the storage without using put method?", //$NON-NLS-1$ - "No idea.", true); //$NON-NLS-1$ - } - - private void updateConnectionName() { - - synchronized (nextConnectionIdLock) { - setConnectionName(getUrl() + nextConnectionId); - nextConnectionId++; - } - - if (resourceManager != null) { - resourceManager.setConfiguration(this); - } - - if (connection == null) { - return; - } - - final SMOARemoteServices smoaRemoteServices = (SMOARemoteServices) PTPRemoteCorePlugin.getDefault().getRemoteServices( - getRemoteServicesId()); - - smoaRemoteServices.getConnectionManager().removeConnection(connection); - connection = null; - isConectionInitialized = false; - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerControl.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerControl.java deleted file mode 100644 index a00bdd542..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerControl.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration; -import org.eclipse.ptp.rm.smoa.core.rtsystem.SMOARuntimeSystem; -import org.eclipse.ptp.rtsystem.AbstractRuntimeResourceManagerControl; -import org.eclipse.ptp.rtsystem.IRuntimeSystem; - -public class SMOAResourceManagerControl extends AbstractRuntimeResourceManagerControl { - /** Current configuration of this RM */ - /* package access */SMOAConfiguration configuration; - - public SMOAResourceManagerControl(SMOAResourceManagerConfiguration config) { - super(config); - configuration = config; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rtsystem.AbstractRuntimeResourceManagerControl#doControlJob - * (java.lang.String, java.lang.String, - * org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected void doControlJob(String jobId, String operation, IProgressMonitor monitor) throws CoreException { - if (operation.equals(TERMINATE_OPERATION)) { - JobThread job = getResourceManager().getJobThread(jobId); - if (job != null) { - job.terminate(); - } - } - super.doControlJob(jobId, operation, monitor); - } - - @Override - protected SMOAResourceManager getResourceManager() { - return (SMOAResourceManager) super.getResourceManager(); - } - - @Override - protected SMOARuntimeSystem getRuntimeSystem() { - final IRuntimeSystem rs = super.getRuntimeSystem(); - if (rs instanceof SMOARuntimeSystem) { - return (SMOARuntimeSystem) rs; - } - throw new RuntimeException(); - } - -}
\ No newline at end of file diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerFactory.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerFactory.java deleted file mode 100644 index 88c5537e1..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerFactory.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory; -import org.eclipse.ptp.rmsystem.IResourceManager; -import org.eclipse.ptp.rmsystem.IResourceManagerComponentConfiguration; -import org.eclipse.ptp.rmsystem.IResourceManagerConfiguration; -import org.eclipse.ptp.rmsystem.IResourceManagerControl; -import org.eclipse.ptp.rmsystem.IResourceManagerMonitor; -import org.eclipse.ptp.services.core.IServiceProvider; - -/** - * @since 5.0 - */ -public class SMOAResourceManagerFactory extends AbstractResourceManagerFactory { - private SMOAResourceManagerConfiguration fConfiguration; - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory#create(org.eclipse - * .ptp.rmsystem.IResourceManagerConfiguration, - * org.eclipse.ptp.rmsystem.IResourceManagerControl, - * org.eclipse.ptp.rmsystem.IResourceManagerMonitor) - */ - @Override - public IResourceManager create(IResourceManagerConfiguration configuration, IResourceManagerControl control, - IResourceManagerMonitor monitor) { - return new SMOAResourceManager((SMOAResourceManagerConfiguration) configuration, (SMOAResourceManagerControl) control, - (SMOAResourceManagerMonitor) monitor); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory#createConfiguration - * (org.eclipse.ptp.services.core.IServiceProvider) - */ - @Override - public IResourceManagerConfiguration createConfiguration(IServiceProvider provider) { - return createCommonConfiguration(provider); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory#createControl - * (org.eclipse.ptp.rmsystem.IResourceManagerComponentConfiguration) - */ - @Override - public IResourceManagerControl createControl(IResourceManagerComponentConfiguration configuration) { - return new SMOAResourceManagerControl((SMOAResourceManagerConfiguration) configuration); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory# - * createControlConfiguration - * (org.eclipse.ptp.services.core.IServiceProvider) - */ - @Override - public IResourceManagerComponentConfiguration createControlConfiguration(IServiceProvider provider) { - return createCommonConfiguration(provider); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory#createMonitor - * (org.eclipse.ptp.rmsystem.IResourceManagerComponentConfiguration) - */ - @Override - public IResourceManagerMonitor createMonitor(IResourceManagerComponentConfiguration configuration) { - return new SMOAResourceManagerMonitor((SMOAResourceManagerConfiguration) configuration); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory# - * createMonitorConfiguration - * (org.eclipse.ptp.services.core.IServiceProvider) - */ - @Override - public IResourceManagerComponentConfiguration createMonitorConfiguration(IServiceProvider provider) { - return createCommonConfiguration(provider); - } - - private SMOAResourceManagerConfiguration createCommonConfiguration(IServiceProvider provider) { - if (fConfiguration == null) { - fConfiguration = new SMOAResourceManagerConfiguration(SMOAResourceManagerConfiguration.BASE, provider); - } - return fConfiguration; - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerMonitor.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerMonitor.java deleted file mode 100644 index f8fcf9dfd..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/SMOAResourceManagerMonitor.java +++ /dev/null @@ -1,468 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rmsystem; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.ptp.core.attributes.ArrayAttribute; -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.BooleanAttribute; -import org.eclipse.ptp.core.attributes.IntegerAttribute; -import org.eclipse.ptp.core.attributes.StringAttribute; -import org.eclipse.ptp.core.elements.IPJob; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; -import org.eclipse.ptp.core.elements.attributes.JobAttributes; -import org.eclipse.ptp.remote.core.IRemoteConnection; -import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; -import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration; -import org.eclipse.ptp.rm.smoa.core.attrib.SMOAJobAttributes; -import org.eclipse.ptp.rm.smoa.core.attrib.StringMapAttribute; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOAConnection; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOARemoteServices; -import org.eclipse.ptp.rm.smoa.core.rtsystem.SMOARuntimeSystem; -import org.eclipse.ptp.rm.smoa.core.util.NotifyShell; -import org.eclipse.ptp.rtsystem.AbstractRuntimeResourceManagerMonitor; -import org.eclipse.ptp.rtsystem.IRuntimeSystem; - -import com.smoa.comp.sdk.SMOAFactory; -import com.smoa.comp.sdk.exceptions.InvalidRequestMessageException; -import com.smoa.comp.sdk.exceptions.NotAuthorizedException; -import com.smoa.comp.sdk.exceptions.UnsupportedFeatureException; -import com.smoa.comp.sdk.jsdl.JSDL; -import com.smoa.comp.sdk.types.ActivityEndpointReference; -import com.smoa.comp.stubs.factory.ApplicationsType.Application; - -public class SMOAResourceManagerMonitor extends AbstractRuntimeResourceManagerMonitor { - - /** - * Extracts from the {@link AttributeManager} proper executable name and - * arguments - * - * Returns the list containing program path and executable (as first - * element) and all arguments (as next arguments) - */ - private static List<String> getExecAndArgs(AttributeManager attrs, IRemoteConnection conn, Application app) { - final List<String> result = new Vector<String>(); - - final BooleanAttribute debug = attrs.getAttribute(JobAttributes.getDebugFlagAttributeDefinition()); - - // // // // // // // // - // // // debug // // // - - if (debug != null && debug.getValue() == true) { - String execPath = attrs.getAttribute(JobAttributes.getDebuggerExecutablePathAttributeDefinition()).getValue(); - - if (execPath == null || execPath.isEmpty()) { - execPath = "."; //$NON-NLS-1$ - } - - final String execName = attrs.getAttribute(JobAttributes.getDebuggerExecutableNameAttributeDefinition()).getValue(); - - final String execPathAndName = execPath + "/" + execName; //$NON-NLS-1$ - - result.add(execPathAndName); - - /* Arguments */ - - final List<String> appArguments = attrs.getAttribute(JobAttributes.getDebuggerArgumentsAttributeDefinition()) - .getValue(); - - if (conn.supportsTCPPortForwarding()) { - final Pattern portRegex = Pattern.compile("^--port=(\\d+)$"); //$NON-NLS-1$ - final Pattern hostRegex = Pattern.compile("^--host=(.+)$"); //$NON-NLS-1$ - - Integer port = null; - String host = null; - - for (final String arg : appArguments) { - Matcher m = portRegex.matcher(arg); - if (m.matches()) { - port = Integer.parseInt(m.group(1)); - } - m = hostRegex.matcher(arg); - if (m.matches()) { - host = m.group(1); - } - } - if (port != null && host != null) { - try { - conn.forwardRemotePort(port, host, port); - } catch (final RemoteConnectionException e) { - NotifyShell.open(Messages.SMOAResourceManager_PortForwardingFailed_title, - Messages.SMOAResourceManager_PortForwardingFailed_text + e.getLocalizedMessage()); - } - } - } - - result.addAll(appArguments); - - final String appString = attrs.getAttribute(SMOAJobAttributes.getAppNameDef()).getValue(); - if (SMOAJobAttributes.NO_WRAPPER_SCRIPT.equals(appString) || app == null) { - result.add("--server=0"); //$NON-NLS-1$ - } - } - - // // // // // // // // - // // / / run / / // // - else { - String execPath = attrs.getAttribute(JobAttributes.getExecutablePathAttributeDefinition()).getValue(); - - if (execPath == null || execPath.isEmpty()) { - execPath = "."; //$NON-NLS-1$ - } - - final String execName = attrs.getAttribute(JobAttributes.getExecutableNameAttributeDefinition()).getValue(); - - final String execPathAndName = execPath + "/" + execName; //$NON-NLS-1$ - - result.add(execPathAndName); - - /* Arguments */ - - final List<String> appArguments = attrs.getAttribute(JobAttributes.getProgramArgumentsAttributeDefinition()).getValue(); - result.addAll(appArguments); - } - - return result; - } - - /** Current configuration of this RM */ - /* package access */SMOAConfiguration configuration; - - /** Assigns sequential run number for each configuration */ - private final Map<String, Integer> executeCount = new HashMap<String, Integer>(); - - public SMOAResourceManagerMonitor(SMOAResourceManagerConfiguration config) { - super(config); - configuration = config; - } - - /** - * Creates script if the user selected an application only. - * - * @param args - * - user arguments - * @param app - * - user application - * @param out - * - file name for stdout - * @param err - * - file name for stderr - * @param os - * - output stream for the script - * @param make - * - if the user wants us to run 'make' - * @param customMakeCommand - * - non-null if user wants to use custom run command - */ - private void createScript(List<String> args, String app, String out, String err, DataOutputStream os, boolean make, - String customMakeCommand) throws IOException { - os.writeBytes("rm -f " + out + " " + err + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - final StringBuilder redirect = new StringBuilder(); - redirect.append(" >> "); //$NON-NLS-1$ - redirect.append(out); - redirect.append(" 2>> "); //$NON-NLS-1$ - redirect.append(err); - - if (make) { - os.writeBytes("echo $(date) Running make >> " + err + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - os.writeBytes("{ "); //$NON-NLS-1$ - if (customMakeCommand != null) { - os.writeBytes(customMakeCommand); - } else { - os.writeBytes("make clean && make"); //$NON-NLS-1$ - } - os.writeBytes(" ; } "); //$NON-NLS-1$ - os.writeBytes(redirect.toString()); - os.writeBytes("\n"); //$NON-NLS-1$ - os.writeBytes("MAKEOUT=$?\n"); //$NON-NLS-1$ - os.writeBytes("if [ ${MAKEOUT} -ne 0 ]\n"); //$NON-NLS-1$ - os.writeBytes("then\n"); //$NON-NLS-1$ - os.writeBytes(" echo $(date) Make failed! Quitting. >> " + err //$NON-NLS-1$ - + "\n"); //$NON-NLS-1$ - os.writeBytes(" exit ${MAKEOUT}\n"); //$NON-NLS-1$ - os.writeBytes("fi\n"); //$NON-NLS-1$ - } - - os.writeBytes("STDBUF=$(which stdbuf)\n"); //$NON-NLS-1$ - os.writeBytes("if [ \"${STDBUF}\" ]\n"); //$NON-NLS-1$ - os.writeBytes("then\n"); //$NON-NLS-1$ - os.writeBytes(" STDBUF=\"${STDBUF} -oL -eL \"\n"); //$NON-NLS-1$ - os.writeBytes("fi\n"); //$NON-NLS-1$ - os.writeBytes("echo $(date) Starting task >> " + err + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - os.writeBytes("{ time ${STDBUF}"); //$NON-NLS-1$ - - // app - os.writeBytes(app); - - // arguments - for (final String arg : args) { - os.write(' '); - os.writeBytes(arg); - } - - os.writeBytes(" ; }"); //$NON-NLS-1$ - - os.writeBytes(redirect.toString()); - os.write('\n'); - - os.writeBytes("OUT=$?\n"); //$NON-NLS-1$ - os.writeBytes("echo $(date) Finished! >> " + err + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - os.writeBytes("exit ${OUT}\n"); //$NON-NLS-1$ - - } - - /** - * In case the submission failed, we set the job state and forward error - */ - private IPJob jobControlFromJobException(Exception e, String jobId, AttributeManager attrs) { - final String subId = attrs.getAttribute(JobAttributes.getSubIdAttributeDefinition()).getValue(); - - attrs.addAttribute(PoolingIntervalsAndStatic.exceptionAttrDef.create(e.getLocalizedMessage())); - attrs.addAttribute(JobAttributes.getStateAttributeDefinition().create(JobAttributes.State.COMPLETED)); - attrs.addAttribute(JobAttributes.getStatusAttributeDefinition().create(Messages.SMOAResourceManager_JobSubmissionFailed)); - - getRuntimeSystem().addJobSubmissionError(subId, e); - - final IPJob newJob = super.doCreateJob(jobId, attrs); - return newJob; - } - - /** - * Adds the SMOA UUID of the activity to job properties - */ - private void setSmoaUid(String smoaUid, IPJob newJob) { - final AttributeManager am = new AttributeManager(); - - final Collection<IPJob> jc = new Vector<IPJob>(); - jc.add(newJob); - - am.addAttribute(SMOAJobAttributes.getSmoaUuidDef().create(smoaUid)); - - doUpdateJobs(jc, am); - } - - /** - * Triggered by fireCreateJobEvent by {@link SMOARuntimeSystem}, creates the - * job and submits it to the SMOA Computing service. - */ - @Override - protected IPJob doCreateJob(String jobId, AttributeManager attrs) { - - // all temporary files are timestamped with the time generated below: - final long time = System.currentTimeMillis(); - - final SMOAConnection connection = configuration.getConnection(); - final SMOAFactory factory = connection.getFactory(); - - final String originalName = attrs.getAttribute(ElementAttributes.getNameAttributeDefinition()).getValueAsString(); - - // Name for SMOA Computing - final JSDL jsdl = new JSDL(originalName); - final List<String> arguments = jsdl.getArguments(); - - Integer count = executeCount.get(originalName); - if (count == null) { - executeCount.put(originalName, 0); - count = 0; - } - - // Label for Eclipse - attrs.addAttribute(ElementAttributes.getNameAttributeDefinition().create(originalName + " (" + count + ")")); //$NON-NLS-1$ //$NON-NLS-2$ - - executeCount.put(originalName, ++count); - - // Working directory - final String workDir = attrs.getAttribute(JobAttributes.getWorkingDirectoryAttributeDefinition()).getValue(); - if (workDir != null) { - jsdl.setWorkingDirectory(workDir); - } - - // Setting program - final SMOARemoteServices remoteServices = (SMOARemoteServices) PTPRemoteCorePlugin.getDefault().getRemoteServices( - configuration.getRemoteServicesId()); - - final String appString = attrs.getAttribute(SMOAJobAttributes.getAppNameDef()).getValue(); - final Application app = configuration.getAppForName(appString); - - final List<String> execArgsAndPath = getExecAndArgs(attrs, connection, app); - - final String execPathAndName = execArgsAndPath.get(0); - final List<String> appArguments = execArgsAndPath.subList(1, execArgsAndPath.size()); - - jsdl.setOutput("stdout"); //$NON-NLS-1$ - jsdl.setError("stderr"); //$NON-NLS-1$ - - // filenames for out and err, and filename for shell script to be - // executed or for the machine file - final String out = connection.getHomeDir() + "/.ptp_smoa_out_" + time; //$NON-NLS-1$ - final String err = connection.getHomeDir() + "/.ptp_smoa_err_" + time; //$NON-NLS-1$ - String machinefile = null; - String sh = null; - - // Custom Make command - String customMakeCommand = null; - - final BooleanAttribute ifCustomMake = attrs.getAttribute(SMOAJobAttributes.getIfCustomMakeDef()); - if (ifCustomMake != null && ifCustomMake.getValue() != null && ifCustomMake.getValue()) { - final StringAttribute makeCommand = attrs.getAttribute(SMOAJobAttributes.getCustomMakeCommandDef()); - if (makeCommand != null && makeCommand.getValue() != null && !makeCommand.getValue().isEmpty()) { - customMakeCommand = makeCommand.getValue(); - } - } - - // If wrapper script has to be used - if (SMOAJobAttributes.NO_WRAPPER_SCRIPT.equals(appString) || app == null) { - - sh = connection.getHomeDir() + "/.ptp_smoa_sh_" + time; //$NON-NLS-1$ - - final BooleanAttribute makeAttr = attrs.getAttribute(SMOAJobAttributes.getMakeDef()); - final boolean make = (makeAttr == null ? false : makeAttr.getValue()); - - // Creating script - try { - final DataOutputStream os = new DataOutputStream(remoteServices.getFileManager(connection).getResource(sh) - .openOutputStream(0, null)); - createScript(appArguments, execPathAndName, out, err, os, make, customMakeCommand); - os.close(); - } catch (final IOException e) { - NotifyShell.open(Messages.SMOAResourceManager_7, e.getLocalizedMessage()); - return jobControlFromJobException(e, jobId, attrs); - } catch (final CoreException e) { - NotifyShell.open(Messages.SMOAResourceManager_8, e.getLocalizedMessage()); - return jobControlFromJobException(e, jobId, attrs); - } - - jsdl.setExecutable("/bin/sh"); //$NON-NLS-1$ - arguments.add(sh); - } - // If the built-in application has to be used - else { - machinefile = connection.getHomeDir() + "/.ptp_smoa_machinefile_" //$NON-NLS-1$ - + time; - - jsdl.setApplicationName(app.getName()); - jsdl.setApplicationVersion(app.getVersion()); - - arguments.add(execPathAndName); - arguments.addAll(appArguments); - - jsdl.getEnvironment().put(SMOAJobAttributes.ENV_STDOUT, out); - jsdl.getEnvironment().put(SMOAJobAttributes.ENV_STDERR, err); - jsdl.getEnvironment().put(SMOAJobAttributes.ENV_MACHINEFILE, machinefile); - - if (customMakeCommand != null) { - jsdl.getEnvironment().put(SMOAJobAttributes.ENV_MAKE_COMMAND, customMakeCommand); - } - - } - - // Others - - final StringAttribute attribute1 = attrs.getAttribute(SMOAJobAttributes.getDescDef()); - if (attribute1 != null && attribute1.getValue() != null && (!attribute1.getValue().isEmpty())) { - jsdl.setJobDescription(attribute1.getValue()); - } - - final StringAttribute attribute2 = attrs.getAttribute(SMOAJobAttributes.getNativeSpecDef()); - if (attribute2 != null && attribute2.getValue() != null && (!attribute2.getValue().isEmpty())) { - jsdl.setNativeSpecification(attribute2.getValue()); - } - - final IntegerAttribute attribute3 = attrs.getAttribute(SMOAJobAttributes.getMinCpuDef()); - if (attribute3 != null && attribute3.getValue() != null) { - jsdl.setMinCpu(attribute3.getValue()); - } - - final IntegerAttribute attribute4 = attrs.getAttribute(SMOAJobAttributes.getMaxCpuDef()); - if (attribute4 != null && attribute4.getValue() != null) { - jsdl.setMaxCpu(attribute4.getValue()); - } - - final ArrayAttribute<String> attribute5 = attrs.getAttribute(SMOAJobAttributes.getPrefferedDef()); - if (attribute5 != null && attribute5.getValue() != null) { - for (final String machineName : attribute5.getValue()) { - jsdl.getCandidateHosts().add(machineName); - } - } - - final StringMapAttribute attribute6 = attrs.getAttribute(SMOAJobAttributes.getEnvDef()); - if (attribute6 != null && (!attribute6.getValue().isEmpty())) { - jsdl.getEnvironment().putAll(attribute6.getValue()); - } - - final BooleanAttribute attribute7 = attrs.getAttribute(SMOAJobAttributes.getMakeDef()); - if (attribute7 != null && attribute7.getValue()) { - jsdl.getEnvironment().put(SMOAJobAttributes.ENV_IF_MAKE, "1"); //$NON-NLS-1$ - } else { - jsdl.getEnvironment().remove(SMOAJobAttributes.ENV_IF_MAKE); - } - - final StringAttribute attribute8 = attrs.getAttribute(SMOAJobAttributes.getQueueNameDef()); - if (attribute8 != null && attribute8.getValue() != null && (!attribute8.getValue().isEmpty())) { - jsdl.setQueueName(attribute8.getValue()); - } - - ActivityEndpointReference activityReference; - - // Submitting the job - try { - activityReference = factory.createActivity(jsdl); - } catch (final InvalidRequestMessageException e) { - return jobControlFromJobException(e, jobId, attrs); - } catch (final NotAuthorizedException e) { - return jobControlFromJobException(e, jobId, attrs); - } catch (final UnsupportedFeatureException e) { - return jobControlFromJobException(e, jobId, attrs); - } catch (final Throwable t) { - throw new RuntimeException(t); - } - - final IPJob jobControl = super.doCreateJob(jobId, attrs); - - setSmoaUid(activityReference.getActivityUUID(), jobControl); - - // Starting job monitoring thread - final JobThread jobThread = new JobThread(getResourceManager(), factory, activityReference, jobControl, out, err, sh, - machinefile); - getResourceManager().addJobThread(jobControl.getID(), jobThread); - jobThread.start(); - - return jobControl; - } - - @Override - protected SMOAResourceManager getResourceManager() { - return (SMOAResourceManager) super.getResourceManager(); - } - - @Override - protected SMOARuntimeSystem getRuntimeSystem() { - final IRuntimeSystem rs = super.getRuntimeSystem(); - if (rs instanceof SMOARuntimeSystem) { - return (SMOARuntimeSystem) rs; - } - throw new RuntimeException(); - } - -}
\ No newline at end of file diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/messages.properties b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/messages.properties deleted file mode 100644 index 689915e25..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rmsystem/messages.properties +++ /dev/null @@ -1,28 +0,0 @@ -JobThread_ErrorDeletingTempFiles_text=Could not remove temporary files\n -JobThread_ErrorDeletingTempFiles_title=Clean-up problem -JobThread_ErrorErr=Error occured while retreiving stderr -JobThread_ErrorOpeningRemote=Error by opening remote file\! -JobThread_ErrorOut=Error occured while retreiving stdout -JobThread_ErrorReadingRemote=Error by reading remote file\! -JobThread_ExceptionByMonitoring=Exception occured by monitoring job -JobThread_JobStateCancelled=Job was cancelled -JobThread_JobStateFailed=Job failed -JobThread_JobStateFinisedWithStatus=Job finished with exit status: -JobThread_JobStateUnknown=Unknown -JobThread_UnknownNode_text_1=Reported process on an unknown node:\n -JobThread_UnknownNode_text_2=\n The node has been added to node list. -JobThread_UnknownNode_title=Error\! -PoolingIntervalsAndStatic_JobSubmissionFailed=Job submission failed -SMOAResourceManager_7=Failed to write the run script on remote host -SMOAResourceManager_8=Failed to create run script on remote host -SMOAResourceManager_JobSubmissionFailed=Exception by submitting occured -SMOAResourceManager_PortForwardingFailed_text=Continuing without port forwarding.\nError:\n -SMOAResourceManager_PortForwardingFailed_title=Port forwarding problem -SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_text=Specified connection no longer exists, falling back to SMOA built-ins. Please update the configuration. -SMOAResourceManagerConfiguration_AdditionalConnectionNotAvailable_title=Configuration error -SMOAResourceManagerConfiguration_CouldNotRetreivePassword=Coud not retreive password\!\! -SMOAResourceManagerConfiguration_CouldNotStorePassword=Coud not store password\!\! -SMOAResourceManagerConfiguration_PrefixAnonymous=[anonymous] -SMOAResourceManagerConfiguration_PrefixGsi=[GSI] -SMOAResourceManagerConfiguration_ReusingConnection=Reusing existing SMOA connection -SMOAResourceManagerConfiguration_SmoaRmDescription=SMOA Computing Resource Manager diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/Messages.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/Messages.java deleted file mode 100644 index 608a93d98..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/Messages.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.ptp.rm.smoa.core.rservices.messages"; //$NON-NLS-1$ - public static String SMOAConnection_CannotModifyOpenConnection; - public static String SMOAConnection_UnsupportedAuthType; - public static String SMOAConnectionManager_DuplicatedConnection; - public static String SMOAFileStore_ChmodFailed; - public static String SMOAFileStore_InputStreamForFileNotReceived; - public static String SMOAFileStore_MkdirOverAnExistingFile; - public static String SMOAFileStore_RequestedListingUnexistingDirOrFile; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnection.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnection.java deleted file mode 100644 index c6f1aaa8e..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnection.java +++ /dev/null @@ -1,410 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.util.Map; - -import javax.xml.bind.JAXBException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ptp.remote.core.IRemoteConnection; -import org.eclipse.ptp.remote.core.IRemoteConnectionChangeListener; -import org.eclipse.ptp.remote.core.IRemoteFileManager; -import org.eclipse.ptp.remote.core.IRemoteServices; -import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration.AuthType; - -import com.smoa.comp.sdk.SMOAFactory; -import com.smoa.comp.sdk.SMOARsync; -import com.smoa.comp.sdk.SMOAStaging; -import com.smoa.comp.sdk.jsdl.JSDL; -import com.smoa.comp.stubs.staging.FileNotFoundFault; -import com.smoa.comp.stubs.staging.NotAuthorizedFault; -import com.smoa.core.sdk.attachments.FileStagingHandler; -import com.smoa.core.sdk.security.AuthenticationModule; -import com.smoa.core.sdk.security.anonymous.AnonymousAuthentication; -import com.smoa.core.sdk.security.gsi.GSIAuthentication; -import com.smoa.core.sdk.security.ssl.SSLAuthentication; -import com.smoa.core.sdk.security.wsse.WSSEAuthentication; -import com.smoa.core.sdk.security.wsse.username.UsernameToken; - -/** - * Main class for maintaining the real connection with SMOA Computing. - * - * Keeps the SMOAFactory, SMOAStaging and SMOARsync objects. - */ -public class SMOAConnection implements IRemoteConnection { - - // Keys for map used to transfer connection attributes - public static final String TAG_ADDRESS = "address"; //$NON-NLS-1$ - public static final String TAG_PORT = "port"; //$NON-NLS-1$ - public static final String TAG_AUTHTYPE = "auth"; //$NON-NLS-1$ - public static final String TAG_USERNAME = "user"; //$NON-NLS-1$ - public static final String TAG_PASSWORD = "pass"; //$NON-NLS-1$ - public static final String TAG_CACERT = "cacert"; //$NON-NLS-1$ - public static final String TAG_DN = "dn"; //$NON-NLS-1$ - - // parent RemoteServices - private final SMOARemoteServices remoteServices; - - // Connection state - private boolean connectionIsOpen = false; - - // Crucial objects - private SMOAFactory besFactory; - private SMOAStaging smoaStaging; - private SMOARsync rsync; - - // Connection info - private String name = null; - private String url = null; - private int port = 0; - private String resourceManagerName; - - // Authentication info - private AuthType auth; - private String username; - private String password; - private String dn; - private String cacert; - - // Others - private IRemoteFileManager fileManager = null; - private String workDir = "."; //$NON-NLS-1$ - private String homeDir = null; - private IRemoteConnection fileRemoteConnection = null; - - public SMOAConnection(SMOARemoteServices remoteServices, String name) { - this.remoteServices = remoteServices; - this.name = name; - } - - public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) { - if (fileRemoteConnection != null) { - fileRemoteConnection.addConnectionChangeListener(listener); - } - - } - - public void close() { - if (fileRemoteConnection != null) { - fileRemoteConnection.close(); - } - } - - public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException { - if (fileRemoteConnection != null) { - fileRemoteConnection.forwardLocalPort(localPort, fwdAddress, fwdPort); - } - - } - - public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException { - if (fileRemoteConnection != null) { - return fileRemoteConnection.forwardLocalPort(fwdAddress, fwdPort, monitor); - } - return 0; - } - - public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException { - if (fileRemoteConnection != null) { - fileRemoteConnection.forwardRemotePort(remotePort, fwdAddress, fwdPort); - } - - } - - public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException { - if (fileRemoteConnection != null) { - return fileRemoteConnection.forwardRemotePort(fwdAddress, fwdPort, monitor); - } - return 0; - } - - public String getAddress() { - return url; - } - - public Map<String, String> getAttributes() { - // TODO Auto-generated method stub - return null; - } - - public Map<String, String> getEnv() { - // TODO Auto-generated method stub - return null; - } - - public String getEnv(String name) { - // TODO Auto-generated method stub - return null; - } - - public SMOAFactory getFactory() { - return besFactory; - } - - public IRemoteConnection getFileConnection() { - return fileRemoteConnection; - } - - public IRemoteFileManager getFileManager() { - return fileManager; - } - - public String getHomeDir() { - if (homeDir != null) { - return homeDir; - } - - if (!isOpen()) { - return "."; //$NON-NLS-1$ - } - - JSDL jsdl; - try { - jsdl = smoaStaging.listDirectory(".", null); //$NON-NLS-1$ - } catch (final FileNotFoundFault e) { - throw new RuntimeException(); - } catch (final NotAuthorizedFault e) { - throw new RuntimeException(); - } - homeDir = jsdl.getWorkingDirectory(); - return homeDir; - - } - - public String getName() { - return name; - } - - public int getPort() { - return port; - } - - public String getProperty(String key) { - // TODO Auto-generated method stub - return null; - } - - public IRemoteServices getRemoteServices() { - return remoteServices; - } - - public String getRMName() { - return resourceManagerName; - } - - public SMOARsync getRsync() { - return rsync; - } - - public SMOAStaging getSMOAStaging() { - return smoaStaging; - } - - public String getUsername() { - return username; - } - - public String getWorkingDirectory() { - if (workDir.equals(".")) { //$NON-NLS-1$ - getHomeDir(); - if (homeDir != null) { - workDir = getHomeDir(); - } else { - return "."; //$NON-NLS-1$ - } - } - if (fileRemoteConnection != null) { - fileRemoteConnection.setWorkingDirectory(workDir); - } - return workDir; - } - - public boolean isOpen() { - if (fileRemoteConnection != null && !fileRemoteConnection.isOpen()) { - return false; - } - return connectionIsOpen; - } - - public void open(IProgressMonitor monitor) throws RemoteConnectionException { - try { - final AnonymousAuthentication anonAuth = new AnonymousAuthentication(); - final FileStagingHandler fileStagingHandler = new SMOAFileStagingHandler(); - - switch (auth) { - case Anonymous: - besFactory = new SMOAFactory(url, port, anonAuth, true); - smoaStaging = new SMOAStaging(url, port, anonAuth, true, fileStagingHandler); - rsync = new SMOARsync(url, port, anonAuth, true); - break; - case GSI: - final GSIAuthentication gsi = new GSIAuthentication(dn != null && !dn.isEmpty() ? dn : null); - besFactory = new SMOAFactory(url, port, gsi, true); - smoaStaging = new SMOAStaging(url, port, gsi, true, fileStagingHandler); - rsync = new SMOARsync(url, port, gsi, true); - - break; - case UsernamePassword: { - - final WSSEAuthentication wsseAuth = new WSSEAuthentication(new UsernameToken(username, password, false, false)); - - AuthenticationModule am; - - if (cacert == null) { - am = anonAuth; - } else { - am = new SSLAuthentication(cacert, null, dn != null && !dn.isEmpty() ? dn : null); - - } - - rsync = new SMOARsync(url, port, am, wsseAuth); - besFactory = new SMOAFactory(url, port, am, wsseAuth); - smoaStaging = new SMOAStaging(url, port, am, wsseAuth, true, fileStagingHandler); - - break; - } - default: - throw new RuntimeException(Messages.SMOAConnection_UnsupportedAuthType); - } - connectionIsOpen = true; - - } catch (final JAXBException e) { - throw new RemoteConnectionException(e); - } catch (final IOException e) { - throw new RemoteConnectionException(e); - } catch (final GeneralSecurityException e) { - throw new RemoteConnectionException(e); - } - if (fileRemoteConnection != null) { - fileRemoteConnection.open(monitor); - } - } - - public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) { - if (fileRemoteConnection != null) { - fileRemoteConnection.removeConnectionChangeListener(listener); - } - - } - - public void setAddress(String address) { - if (address == null) { - return; - } - if (address.equals(url)) { - return; - } - if (isOpen()) { - throw new RuntimeException(Messages.SMOAConnection_CannotModifyOpenConnection); - } - url = address; - } - - public void setAuthType(AuthType auth) { - if (this.auth == auth) { - return; - } - if (isOpen()) { - throw new RuntimeException(Messages.SMOAConnection_CannotModifyOpenConnection); - } - this.auth = auth; - } - - public void setCaCert(String string) { - cacert = string; - } - - public void setDN(String string) { - dn = string; - } - - public void setFileConnection(IRemoteConnection fileRemoteConnection) { - if (isOpen()) { - throw new RuntimeException(Messages.SMOAConnection_CannotModifyOpenConnection); - } - this.fileRemoteConnection = fileRemoteConnection; - } - - public void setFileManager(IRemoteFileManager fileManager) { - this.fileManager = fileManager; - } - - public void setName(String name) { - this.name = name; - } - - public void setPort(int port) { - if (this.port == port) { - return; - } - if (isOpen()) { - throw new RuntimeException(Messages.SMOAConnection_CannotModifyOpenConnection); - } - this.port = port; - } - - public void setRMName(String rMName) { - resourceManagerName = rMName; - } - - public void setUsername(String username) { - if (isOpen()) { - throw new RuntimeException(); - } - this.username = username; - } - - public void setWorkingDirectory(String path) { - workDir = path; - if (fileRemoteConnection != null) { - fileRemoteConnection.setWorkingDirectory(path); - } - - } - - public boolean supportsTCPPortForwarding() { - if (fileRemoteConnection != null) { - return fileRemoteConnection.supportsTCPPortForwarding(); - } - return false; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.remote.core.IRemoteConnection#setAttribute(java.lang. - * String, java.lang.String) - */ - public void setAttribute(String key, String value) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.remote.core.IRemoteConnection#setPassword(java.lang.String - * ) - */ - public void setPassword(String password) { - if (isOpen()) { - throw new RuntimeException(Messages.SMOAConnection_CannotModifyOpenConnection); - } - this.password = password; - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnectionManager.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnectionManager.java deleted file mode 100644 index b9475eeaf..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAConnectionManager.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.net.URI; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - -import org.eclipse.ptp.remote.core.IRemoteConnection; -import org.eclipse.ptp.remote.core.IRemoteConnectionManager; -import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; - -/** - * Manages existing SMOA connections - */ -public class SMOAConnectionManager implements IRemoteConnectionManager { - - /** Parent Remote Services */ - private final SMOARemoteServices remoteServices; - - /** Map keeping connection under it's name */ - private final Map<String, SMOAConnection> connections = new HashMap<String, SMOAConnection>(); - - public SMOAConnectionManager(SMOARemoteServices remoteServices) { - this.remoteServices = remoteServices; - } - - public SMOAConnection getConnection(String name) { - return connections.get(name); - } - - public SMOAConnection getConnection(URI uri) { - return getConnection(uri.toString()); - } - - /** - * In order to prevent using this Remote Services in other RM's, the - * official connection list is always empty - */ - public SMOAConnection[] getConnections() { - // return connections.values().toArray(new - // SMOAConnection[connections.size()]); - return new SMOAConnection[0]; - } - - /** - * Retrieves all successful connections - */ - public Map<String, SMOAConnection> getOpenConnections() { - final Map<String, SMOAConnection> map = new TreeMap<String, SMOAConnection>(); - for (final Entry<String, SMOAConnection> entry : connections.entrySet()) { - if (entry.getValue().isOpen()) { - map.put(entry.getKey(), entry.getValue()); - } - } - return map; - } - - /** - * Creates a connection, does not open it. - */ - public SMOAConnection newConnection(String name) throws RemoteConnectionException { - - if (connections.containsKey(name)) { - throw new RemoteConnectionException(Messages.SMOAConnectionManager_DuplicatedConnection); - } - - final SMOAConnection connection = new SMOAConnection(remoteServices, name); - - connections.put(name, connection); - - return connection; - } - - public void removeConnection(IRemoteConnection connection) { - connection.close(); - connections.remove(connection.getName()); - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileManager.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileManager.java deleted file mode 100644 index c591cf871..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.net.URI; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.ptp.remote.core.IRemoteFileManager; - -import com.smoa.comp.sdk.SMOAStaging; - -public class SMOAFileManager implements IRemoteFileManager { - - final private SMOAStaging staging; - private final SMOAConnection connection; - - public SMOAFileManager(SMOAConnection c) { - this.connection = c; - staging = c.getSMOAStaging(); - } - - public String getDirectorySeparator() { - return "/"; //$NON-NLS-1$ - } - - public SMOAFileStore getResource(String path) { - return new SMOAFileStore(path, staging, connection, null); - } - - public String toPath(URI uri) { - // TODO Auto-generated method stub - return null; - } - - public URI toURI(IPath path) { - // TODO Auto-generated method stub - return null; - } - - public URI toURI(String path) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStagingHandler.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStagingHandler.java deleted file mode 100644 index 80f7ebe68..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStagingHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; - -import com.smoa.core.sdk.attachments.FileStagingHandler; - -/** - * Staging handler working in cooperation with {@link SMOAFileStore} class. - */ -public class SMOAFileStagingHandler implements FileStagingHandler { - - public synchronized InputStream stageIn(String arg0) throws IOException { - final TransferStream ts = new TransferStream(); - - final SMOAFileStore fileStore = SMOAFileStore.fileStoresWaitingForStaging - .get(arg0); - SMOAFileStore.fileStoresWaitingForOutputStream.put(arg0, ts.os); - - synchronized (fileStore) { - fileStore.notify(); - } - - return ts.is; - } - - public synchronized void stageOut(String arg0, InputStream arg1) - throws IOException { - - SMOAFileStore.fileStoresWaitingForInputStream.put(arg0, arg1); - } -} - -/** - * Two connected Pipe(I/O)Streams. Needed when library has: Input method() and - * user wants: method(Output) - */ -class TransferStream { - PipedInputStream is = new PipedInputStream(); - PipedOutputStream os = new PipedOutputStream(); - { - try { - is.connect(os); - } catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStore.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStore.java deleted file mode 100644 index 38a569555..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOAFileStore.java +++ /dev/null @@ -1,615 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileInfo; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.filesystem.provider.FileStore; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.ptp.rm.smoa.core.SMOACoreActivator; - -import com.smoa.comp.sdk.SMOAStaging; -import com.smoa.comp.sdk.exceptions.DeleteOnTerminationException; -import com.smoa.comp.sdk.exceptions.FileNotFoundException; -import com.smoa.comp.sdk.exceptions.NotAuthorizedException; -import com.smoa.comp.sdk.exceptions.StagingException; -import com.smoa.comp.sdk.jsdl.JSDL; -import com.smoa.comp.sdk.jsdl.JSDLDataStaging; -import com.smoa.comp.sdk.types.FileInfo; -import com.smoa.comp.stubs.staging.FileNotFoundFault; -import com.smoa.comp.stubs.staging.NotAuthorizedFault; -import com.smoa.comp.stubs.staging.StagingFault; - -/** - * Represents a potential file or directory. {@see - * http://help.eclipse.org/helios - * /index.jsp?topic=/org.eclipse.platform.doc.isv/reference - * /api/org/eclipse/core/filesystem/package-summary.html} - */ -public class SMOAFileStore extends FileStore { - - private final SMOAStaging staging; - private final SMOAConnection connection; - - /** Absolute path to file */ - private final String path; - - /** If file exists */ - boolean exists = true; - - private FileInfo info; - - /** Parent file store (i.e. "../") */ - private final SMOAFileStore parent; - - // Maps used to co-operate with {@link SMOAFileStagingHandler} - static public Map<String, SMOAFileStore> fileStoresWaitingForStaging = new ConcurrentHashMap<String, SMOAFileStore>(); - static public Map<String, InputStream> fileStoresWaitingForInputStream = new ConcurrentHashMap<String, InputStream>(); - static public Map<String, OutputStream> fileStoresWaitingForOutputStream = new ConcurrentHashMap<String, OutputStream>(); - - // File info used in case of an error - static final FileInfo errorFileInfo = new FileInfo(0, 0, null, null, 0, - null, null, null); - - private static int counter = 0; - - private static Object ctr_lock = new Object(); - - private static String chmodAttributesFromFileInfo(IFileInfo fileInfo) { - int rights = 0; - - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE)) { - rights |= 01; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OTHER_WRITE)) { - rights |= 02; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OTHER_READ)) { - rights |= 04; - } - - if (fileInfo.getAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE)) { - rights |= 010; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_GROUP_WRITE)) { - rights |= 020; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_GROUP_READ)) { - rights |= 040; - } - - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE)) { - rights |= 0100; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OWNER_WRITE)) { - rights |= 0200; - } - if (fileInfo.getAttribute(EFS.ATTRIBUTE_OWNER_READ)) { - rights |= 0400; - } - - return Integer.toString(rights, 8); - } - - /** - * Constructs new SMOAFileStore, does not fetch the info - * - * @param path - * - may be relative - * @param parent - * - parent directory store - */ - public SMOAFileStore(String path, SMOAStaging staging, - SMOAConnection connection, SMOAFileStore parent) { - super(); - - while (path.endsWith("/") && path.length() > 1) { //$NON-NLS-1$ - path = path.substring(0, path.length() - 1); - } - - while (path.startsWith("./")) { //$NON-NLS-1$ - path = path.substring(2); - } - - if (path.equals(".") || path.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ - path = connection.getHomeDir(); - } - - if (!path.startsWith("/")) { //$NON-NLS-1$ - path = connection.getHomeDir() + "/" + path; //$NON-NLS-1$ - } - - this.path = path; - this.connection = connection; - this.staging = staging; - this.parent = parent; - } - - /** - * Returns last fetched IFileInfo, or null if no info has been fetched yet. - */ - public IFileInfo cachedInfo() throws CoreException { - - org.eclipse.core.filesystem.provider.FileInfo fileInfo; - fileInfo = new org.eclipse.core.filesystem.provider.FileInfo(path); - - fileInfo.setExists(exists); - - if (!exists) { - return fileInfo; - } - - if (info == null) { - return null; - } - - fileInfo.setDirectory((info.getMode() & FileInfo.S_IFDIR) != 0); - - fileInfo.setLastModified(info.getModificationTime().getTime()); - - fileInfo.setLength(info.getSize()); - - fileInfo.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, - (info.getMode() & 0111) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_HIDDEN, getName().matches("^.")); //$NON-NLS-1$ - fileInfo.setAttribute(EFS.ATTRIBUTE_READ_ONLY, - (info.getMode() & 0444) == 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_SYMLINK, - (info.getMode() & FileInfo.S_IFLNK) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE, - (info.getMode() & 0100) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_READ, - (info.getMode() & 0400) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_WRITE, - (info.getMode() & 0200) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE, - (info.getMode() & 010) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_GROUP_READ, - (info.getMode() & 040) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_GROUP_WRITE, - (info.getMode() & 020) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE, - (info.getMode() & 01) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OTHER_READ, - (info.getMode() & 04) != 0); - fileInfo.setAttribute(EFS.ATTRIBUTE_OTHER_WRITE, - (info.getMode() & 02) != 0); - - if ((info.getMode() & FileInfo.S_IFLNK) != 0) { - fileInfo.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET, path); - } - - return fileInfo; - } - - /** - * Returns IFileInfos for all children in this directory. Uses one call for - * all files instead of a call for every file. If fails, falls back to - * default implementation. - */ - @Override - public IFileInfo[] childInfos(int options, IProgressMonitor monitor) - throws CoreException { - - final List<String> fileNames = new Vector<String>(); - final String[] childNames = childNames(options, monitor); - - if (childNames.length == 0) { - return new IFileInfo[0]; - } - - for (final String childName : childNames) { - fileNames.add(path + "/" + childName); //$NON-NLS-1$ - } - - FileInfo[] infos; - try { - infos = staging.statFile(fileNames, null); - } catch (final FileNotFoundFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final NotAuthorizedFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final StagingFault e) { - return super.childInfos(options, monitor); - } - - final SMOAFileStore[] stores = new SMOAFileStore[fileNames.size()]; - final IFileInfo[] smoaInfos = new IFileInfo[fileNames.size()]; - for (int i = 0; i < infos.length; i++) { - stores[i] = fromChildInfo(infos[i], fileNames.get(i)); - smoaInfos[i] = stores[i].cachedInfo(); - } - - return smoaInfos; - } - - /** - * Returns the directory listing (like <tt>ls -1</tt>) - */ - @Override - public String[] childNames(int arg0, IProgressMonitor arg1) - throws CoreException { - - fetchInfo(arg0, arg1); - - if (!exists) { - throw new CoreException(new Status(IStatus.WARNING, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_RequestedListingUnexistingDirOrFile)); - } - - if ((info.getMode() & FileInfo.S_IFDIR) == 0) { - return new String[0]; - } - - JSDL jsdl; - - try { - jsdl = staging.listDirectory(path, null); - } catch (final FileNotFoundFault e) { - throw new RuntimeException(e); - } catch (final NotAuthorizedFault e) { - throw new RuntimeException(e); - } - - final Vector<String> names = new Vector<String>(); - for (final JSDLDataStaging ds : jsdl.getDataStaging()) { - if (ds.getFileName().equals(".") || ds.getFileName().equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$ - continue; - } - names.add(ds.getFileName()); - } - return names.toArray(new String[names.size()]); - } - - @Override - public void delete(int options, IProgressMonitor monitor) - throws CoreException { - try { - staging.delete(path, null); - } catch (final FileNotFoundFault e) { - } catch (final NotAuthorizedFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final StagingFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } - } - - /** - * Fetches info for a single file - */ - @Override - public IFileInfo fetchInfo(int arg0, IProgressMonitor arg1) - throws CoreException { - try { - final List<String> l = new Vector<String>(); - l.add(path); - info = staging.statFile(l, null)[0]; - exists = true; - } catch (final FileNotFoundFault e) { - exists = false; - } catch (final NotAuthorizedFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final StagingFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } - - return cachedInfo(); - - } - - /** - * If one has a FileInfo of a child, one may create FileStore with it - */ - protected SMOAFileStore fromChildInfo(FileInfo info, String path) { - final SMOAFileStore store = new SMOAFileStore(path, staging, connection, this); - store.info = info; - store.exists = true; - return store; - } - - /** - * Returns a file from this directory - * - * @param name - * - name, relative to this directory - */ - @Override - public SMOAFileStore getChild(String name) { - - if (name == null || name.isEmpty()) { - return null; - } - - if (name.equals(".")) { //$NON-NLS-1$ - return this; - } - - if (name.startsWith("/")) { //$NON-NLS-1$ - if (name.startsWith(path) && !name.equals(path)) { - return new SMOAFileStore(name, staging, getConnection(), this); - } - - return new SMOAFileStore(name, staging, getConnection(), null); - } - - if (name.equals("..") || name.contains("/")) { //$NON-NLS-1$ //$NON-NLS-2$ - return new SMOAFileStore(path + "/" + name, staging, //$NON-NLS-1$ - getConnection(), null); - } - - return new SMOAFileStore(path + "/" + name, staging, //$NON-NLS-1$ - getConnection(), this); - } - - public SMOAConnection getConnection() { - return connection; - } - - /** - * Returns file name - */ - @Override - public String getName() { - if (path.endsWith("/") && path.length() > 1) { //$NON-NLS-1$ - final String p = path.substring(0, path.length() - 1); - return p.substring(p.lastIndexOf('/') + 1); - } - return path.substring(path.lastIndexOf('/') + 1); - } - - /** - * Returns (creating if needed) parent store - */ - @Override - public SMOAFileStore getParent() { - if (parent != null) { - return parent; - } - - if (path.indexOf('/') == -1) { - return null; - } - - if (path.equals("/")) { //$NON-NLS-1$ - return null; - } - - final String parentPath = path.substring(0, path.lastIndexOf('/')); - return new SMOAFileStore(parentPath, staging, getConnection(), null); - } - - public String getPath() { - return path; - } - - @Override - public SMOAFileStore mkdir(int options, IProgressMonitor monitor) - throws CoreException { - - if (this.fetchInfo().isDirectory()) { - return this; - } - - if (exists) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_MkdirOverAnExistingFile)); - } - - final IFileStore par = getParent(); - if (!par.fetchInfo().isDirectory()) { - par.mkdir(options, monitor); - } - - try { - staging.mkdir(path, null, null); - } catch (final FileNotFoundFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final NotAuthorizedFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } catch (final StagingFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } - - fetchInfo(); - return this; - } - - /** - * Co-working with {@link SMOAStagingHandler} gets the {@link InputStream} - * from the file - */ - @Override - public InputStream openInputStream(int arg0, IProgressMonitor arg1) - throws CoreException { - return openInputStream(arg0, arg1, 0); - } - - /** - * Co-working with {@link SMOAStagingHandler} gets the {@link InputStream} - * from the file, from specified offset (in bytes) on - */ - public InputStream openInputStream(int arg0, IProgressMonitor arg1, - Integer offset) throws CoreException { - - int lcounter; - synchronized (ctr_lock) { - lcounter = counter; - counter++; - } - - final JSDL jsdl = new JSDL("openInputStream_" + path); //$NON-NLS-1$ - final JSDLDataStaging dataStaging = new JSDLDataStaging(path, null, path - + " " + lcounter); //$NON-NLS-1$ - - dataStaging.setOffset(offset); - - jsdl.getDataStaging().add(dataStaging); - Throwable t; - - try { - staging.stageOutFiles(jsdl); - - final InputStream is = fileStoresWaitingForInputStream.remove(path - + " " + lcounter); //$NON-NLS-1$ - - // FIXME: - if (is == null) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_InputStreamForFileNotReceived)); - } - - return is; - - } catch (final DeleteOnTerminationException e) { - t = e; - } catch (final FileNotFoundException e) { - t = e; - } catch (final NotAuthorizedException e) { - t = e; - } catch (final StagingException e) { - t = e; - } catch (final IOException e) { - t = e; - } - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, t.getLocalizedMessage(), t)); - } - - /** - * Opens {@link OutputStream} for the file. Overwrites if file exists. - * - * If the file doesn't exist, the file is created. - * - * If the parent directory doesn't exist, it's also created. - */ - @Override - public OutputStream openOutputStream(int options, IProgressMonitor monitor) - throws CoreException { - - // Ensure that the parent dir exists - getParent().mkdir(options, monitor); - - int lcounter; - synchronized (ctr_lock) { - lcounter = counter; - counter++; - } - - final JSDL jsdl = new JSDL("openOutputStream_" + path); //$NON-NLS-1$ - jsdl.getDataStaging().add( - new JSDLDataStaging(path, path + " " + lcounter, //$NON-NLS-1$ - null)); - final Throwable[] t = new Throwable[1]; - t[0] = null; - - fileStoresWaitingForStaging.put(path + " " + lcounter, this); //$NON-NLS-1$ - - synchronized (this) { - new Thread() { - @Override - public void run() { - setName("stageIn_" + path); //$NON-NLS-1$ - try { - staging.stageInFiles(jsdl); - } catch (final FileNotFoundException e) { - t[0] = e; - } catch (final NotAuthorizedException e) { - t[0] = e; - } catch (final StagingException e) { - t[0] = e; - } catch (final IOException e) { - t[0] = e; - } - } - }.start(); - - try { - this.wait(); - } catch (final InterruptedException e) { - } - } - - fileStoresWaitingForStaging.remove(path + " " + lcounter); //$NON-NLS-1$ - - final OutputStream os = fileStoresWaitingForOutputStream.remove(path - + " " + lcounter); //$NON-NLS-1$ - - if (t[0] == null) { - return os; - } - - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, t[0].getLocalizedMessage(), t[0])); - } - - /** - * Changes file properties - in SMOA case, only chmod is supported - */ - @Override - public void putInfo(IFileInfo arg0, int arg1, IProgressMonitor arg2) - throws CoreException { - try { - staging.chmod(path, chmodAttributesFromFileInfo(arg0), null); - } catch (final FileNotFoundFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_ChmodFailed - + e.getLocalizedMessage(), e)); - } catch (final NotAuthorizedFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_ChmodFailed - + e.getLocalizedMessage(), e)); - } catch (final StagingFault e) { - throw new CoreException(new Status(IStatus.ERROR, - SMOACoreActivator.PLUGIN_ID, - Messages.SMOAFileStore_ChmodFailed - + e.getLocalizedMessage(), e)); - } - } - - @Override - public URI toURI() { - try { - return new URI(path); - } catch (final URISyntaxException e) { - throw new RuntimeException(e); - } - } - -}
\ No newline at end of file diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOARemoteServices.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOARemoteServices.java deleted file mode 100644 index 232971f85..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/SMOARemoteServices.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rservices; - -import java.util.List; - -import org.eclipse.ptp.remote.core.IRemoteConnection; -import org.eclipse.ptp.remote.core.IRemoteFileManager; -import org.eclipse.ptp.remote.core.IRemoteProcessBuilder; -import org.eclipse.ptp.remote.core.IRemoteServices; - -/** - * SMOARemoteServices provide services for managing connection and files, as - * well as hold SMOA objects need for task submission. - * - * But for file managing and creating remote processes one may supply any other - * services, in this case SMOARemoteService will just serve as proxy. - */ -public class SMOARemoteServices implements IRemoteServices { - - private final String remoteServices_ID; - private final String remoteServices_NAME; - private final String remoteServices_SCHEME; - - private SMOAConnectionManager connectionManager = null; - - public SMOARemoteServices(String id, String name) { - remoteServices_ID = id; - remoteServices_NAME = name; - remoteServices_SCHEME = "scheme"; //$NON-NLS-1$ - } - - public SMOAConnectionManager getConnectionManager() { - if (connectionManager == null) { - connectionManager = new SMOAConnectionManager(this); - } - return connectionManager; - } - - public IRemoteFileManager getFileManager(IRemoteConnection conn) { - if (!(conn instanceof SMOAConnection)) { - throw new IllegalArgumentException("SMOA got a " //$NON-NLS-1$ - + conn.getClass().getCanonicalName() + " connection"); //$NON-NLS-1$ - } - final SMOAConnection c = (SMOAConnection) conn; - - if (!c.isOpen()) { - return null; - } - - final IRemoteConnection fileServices = c.getFileConnection(); - if (fileServices != null) { - return fileServices.getRemoteServices() - .getFileManager(fileServices); - } - - IRemoteFileManager fileManager = c.getFileManager(); - - if (fileManager == null) { - fileManager = new SMOAFileManager(c); - c.setFileManager(fileManager); - } - - return fileManager; - } - - public String getId() { - return remoteServices_ID; - } - - public String getName() { - return remoteServices_NAME; - } - - public IRemoteProcessBuilder getProcessBuilder(IRemoteConnection conn, - List<String> command) { - - if (!(conn instanceof SMOAConnection)) { - throw new IllegalArgumentException("SMOA got a " //$NON-NLS-1$ - + conn.getClass().getCanonicalName() + " connection"); //$NON-NLS-1$ - } - final SMOAConnection c = (SMOAConnection) conn; - final IRemoteConnection fileServices = c.getFileConnection(); - if (fileServices != null) { - return fileServices.getRemoteServices().getProcessBuilder( - fileServices, command); - } - - return null; - } - - public IRemoteProcessBuilder getProcessBuilder(IRemoteConnection conn, - String... command) { - - if (!(conn instanceof SMOAConnection)) { - throw new IllegalArgumentException("SMOA got a " //$NON-NLS-1$ - + conn.getClass().getCanonicalName() + " connection"); //$NON-NLS-1$ - } - final SMOAConnection c = (SMOAConnection) conn; - final IRemoteConnection fileServices = c.getFileConnection(); - if (fileServices != null) { - return fileServices.getRemoteServices().getProcessBuilder( - fileServices, command); - } - - return null; - } - - public String getScheme() { - return remoteServices_SCHEME; - } - - public void initialize() { - } - - public boolean isInitialized() { - return true; - } - -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/messages.properties b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/messages.properties deleted file mode 100644 index bbe4cf99f..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rservices/messages.properties +++ /dev/null @@ -1,7 +0,0 @@ -SMOAConnection_CannotModifyOpenConnection=Cannot change an already opened connection -SMOAConnection_UnsupportedAuthType=Unsupported authentication type forced\!\!\! -SMOAConnectionManager_DuplicatedConnection=Trying to add an already existing connection -SMOAFileStore_ChmodFailed=Chmod failed: -SMOAFileStore_InputStreamForFileNotReceived=Receiving InputStream for a file failed -SMOAFileStore_MkdirOverAnExistingFile=Cannot create dir, because the path describes a file -SMOAFileStore_RequestedListingUnexistingDirOrFile=Store does no exist diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystem.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystem.java deleted file mode 100644 index bcb99232f..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystem.java +++ /dev/null @@ -1,457 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.rtsystem; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.ptp.core.IPTPLaunchConfigurationConstants; -import org.eclipse.ptp.core.attributes.AttributeDefinitionManager; -import org.eclipse.ptp.core.attributes.AttributeManager; -import org.eclipse.ptp.core.attributes.IAttribute; -import org.eclipse.ptp.core.attributes.IllegalValueException; -import org.eclipse.ptp.core.elements.IPElement; -import org.eclipse.ptp.core.elements.IPMachine; -import org.eclipse.ptp.core.elements.attributes.ElementAttributeManager; -import org.eclipse.ptp.core.elements.attributes.ElementAttributes; -import org.eclipse.ptp.core.elements.attributes.ErrorAttributes; -import org.eclipse.ptp.core.elements.attributes.FilterAttributes; -import org.eclipse.ptp.core.elements.attributes.JobAttributes; -import org.eclipse.ptp.core.elements.attributes.MachineAttributes; -import org.eclipse.ptp.core.elements.attributes.MessageAttributes; -import org.eclipse.ptp.core.elements.attributes.NodeAttributes; -import org.eclipse.ptp.core.elements.attributes.ProcessAttributes; -import org.eclipse.ptp.core.elements.attributes.QueueAttributes; -import org.eclipse.ptp.core.elements.attributes.ResourceManagerAttributes; -import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; -import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration; -import org.eclipse.ptp.rm.smoa.core.SMOACoreActivator; -import org.eclipse.ptp.rm.smoa.core.attrib.SMOAMachineAttributes; -import org.eclipse.ptp.rm.smoa.core.attrib.SMOANodeAttributes; -import org.eclipse.ptp.rm.smoa.core.attrib.SMOAQueueAttributes; -import org.eclipse.ptp.rm.smoa.core.attrib.SMOARMAttributes; -import org.eclipse.ptp.rm.smoa.core.rmsystem.SMOAResourceManager; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOAConnection; -import org.eclipse.ptp.rm.smoa.core.rservices.SMOARemoteServices; -import org.eclipse.ptp.rtsystem.AbstractRuntimeSystem; -import org.eclipse.ptp.rtsystem.events.IRuntimeEventFactory; -import org.eclipse.ptp.rtsystem.events.IRuntimeJobChangeEvent; -import org.eclipse.ptp.rtsystem.events.IRuntimeNewJobEvent; -import org.eclipse.ptp.rtsystem.events.IRuntimeNewMachineEvent; -import org.eclipse.ptp.rtsystem.events.IRuntimeNewNodeEvent; -import org.eclipse.ptp.rtsystem.events.IRuntimeNewQueueEvent; -import org.eclipse.ptp.rtsystem.events.IRuntimeRMChangeEvent; -import org.eclipse.ptp.rtsystem.events.RuntimeEventFactory; -import org.eclipse.ptp.utils.core.ArgumentParser; -import org.eclipse.ptp.utils.core.RangeSet; - -import com.smoa.comp.sdk.SMOAFactory; -import com.smoa.comp.stubs.bes.factory.BasicResourceAttributesDocumentType; -import com.smoa.comp.stubs.bes.factory.FactoryResourceAttributesDocumentType; -import com.smoa.comp.stubs.factory.ApplicationsType.Application; - -/** - * Co-works with {@link SMOAResourceManager} in order to manage ResourceManager - * and jobs. Is created by {@link SMOAResourceManager}. - * - * Methods from this class are called by Eclipse in order to start and terminate - * a job - */ -public class SMOARuntimeSystem extends AbstractRuntimeSystem { - - private final SMOAConfiguration configuration; - private int nextJobNumber = 0; - - /** Creates events for the ResourceManager */ - private final IRuntimeEventFactory eventFactory = new RuntimeEventFactory(); - - /** Caches errors from {@link SMOAResourceManager} by submitting jobs */ - private final Map<String, Exception> jobSbmissionErrors = new HashMap<String, Exception>(); - - /** Resource Manager ID (needed for RM change events) */ - private final String rmId; - - /** Attribute definitions for the RTS. */ - protected AttributeDefinitionManager attrMgr = new AttributeDefinitionManager(); - - public SMOARuntimeSystem(SMOAConfiguration configuration, String rmId) { - super(); - this.configuration = configuration; - this.rmId = rmId; - } - - public void addJobSubmissionError(String subId, Exception e) { - jobSbmissionErrors.put(subId, e); - } - - public void addUnknownNode(IPMachine machine, String name) { - final AttributeManager am = new SMOANodeAttributes(); - - am.addAttribute(ElementAttributes.getNameAttributeDefinition().create(name)); - am.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create(name)); - - final ElementAttributeManager eam = new ElementAttributeManager(); - eam.setAttributeManager(new RangeSet(machine.getNodes().length), am); - - final IRuntimeNewNodeEvent irnne = eventFactory.newRuntimeNewNodeEvent(machine.getID(), eam); - - fireRuntimeNewNodeEvent(irnne); - } - - public void filterEvents(IPElement element, boolean filterChildren, AttributeManager filterAttributes) throws CoreException { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rtsystem.IControlSystem#getAttributeDefinitionManager() - */ - public AttributeDefinitionManager getAttributeDefinitionManager() { - return attrMgr; - } - - public void shutdown() throws CoreException { - - } - - public void startEvents() throws CoreException { - } - - /** - * Opens the connection and retrieves basic information about RM, machine - * and nodes. Creates the default queue - */ - public void startup(IProgressMonitor monitor) throws CoreException { - - initialize(); - - final SMOARemoteServices remoteServices = (SMOARemoteServices) PTPRemoteCorePlugin.getDefault().getRemoteServices( - configuration.getRemoteServicesId()); - - final SMOAConnection connection = remoteServices.getConnectionManager().getConnection(configuration.getConnectionName()); - - if (!connection.isOpen()) { - try { - connection.open(monitor); - } catch (final RemoteConnectionException e1) { - throw new CoreException(new Status(IStatus.ERROR, SMOACoreActivator.PLUGIN_ID, e1.getLocalizedMessage(), e1)); - } - } - - final SMOAFactory besFactory = connection.getFactory(); - - FactoryResourceAttributesDocumentType cluster; - - try { - cluster = besFactory.getFactoryAttributesDocument(); - } catch (final Throwable t) { - throw new CoreException(new Status(IStatus.ERROR, SMOACoreActivator.PLUGIN_ID, t.getLocalizedMessage(), t)); - } - - final List<Application> apps = SMOAFactory.getApplications(cluster).getApplication(); - - configuration.setAvailableAppList(apps); - - // Machine && nodes information - { - final ElementAttributeManager machines = new ElementAttributeManager(); - final AttributeManager machine = new SMOAMachineAttributes(); - - machine.addAttribute(ElementAttributes.getNameAttributeDefinition().create(cluster.getCommonName())); - - try { - machine.addAttribute(MachineAttributes.getNumNodesAttributeDefinition().create( - cluster.getContainedResource().size())); - } catch (final IllegalValueException e1) { - // One of the "should never happen" - throw new CoreException(new Status(IStatus.ERROR, SMOACoreActivator.PLUGIN_ID, e1.getLocalizedMessage(), e1)); - } - - machines.setAttributeManager(new RangeSet(0), machine); - - final IRuntimeNewMachineEvent irnme = eventFactory.newRuntimeNewMachineEvent(null, machines); - fireRuntimeNewMachineEvent(irnme); - - int i = 0; - - for (final Object _ : cluster.getContainedResource()) { - final BasicResourceAttributesDocumentType host = (BasicResourceAttributesDocumentType) _; - - try { - final AttributeManager am = new SMOANodeAttributes(); - - am.addAttribute(ElementAttributes.getNameAttributeDefinition().create(host.getResourceName())); - am.addAttribute(ProcessAttributes.getNodeIdAttributeDefinition().create(host.getResourceName())); - am.addAttribute(SMOANodeAttributes.getCpuArchDef().create( - host.getCPUArchitecture().getCPUArchitectureName().toString())); - am.addAttribute(SMOANodeAttributes.getCpuCountDef().create(host.getCPUCount().intValue())); - am.addAttribute(SMOANodeAttributes.getMemorySizeDef().create((host.getPhysicalMemory() / (1024 * 1024)) + "MB")); //$NON-NLS-1$ - - am.addAttribute(NodeAttributes.getStateAttributeDefinition().create(NodeAttributes.State.UP)); - - final ElementAttributeManager eam = new ElementAttributeManager(); - eam.setAttributeManager(new RangeSet(i++), am); - - final IRuntimeNewNodeEvent irnne = eventFactory.newRuntimeNewNodeEvent("0", eam); //$NON-NLS-1$ - - fireRuntimeNewNodeEvent(irnne); - - } catch (final IllegalValueException e) { - throw new CoreException(new Status(IStatus.ERROR, SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } - } - - } - - // Queue information - - { - final RangeSet rs = new RangeSet(0); - final AttributeManager am = new SMOAQueueAttributes(); - try { - am.getAttribute("name").setValueAsString("Default queue"); //$NON-NLS-1$ //$NON-NLS-2$ - am.getAttribute("id").setValueAsString("0"); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (final IllegalValueException e) { - throw new RuntimeException(e); - } - - final ElementAttributeManager eam = new ElementAttributeManager(); - eam.setAttributeManager(rs, am); - - final IRuntimeNewQueueEvent irnqe = eventFactory.newRuntimeNewQueueEvent(null, eam); - fireRuntimeNewQueueEvent(irnqe); - } - - // RM informations - - { - - final ElementAttributeManager eam = new ElementAttributeManager(); - final RangeSet rs = new RangeSet(rmId); - final AttributeManager am = new SMOARMAttributes(); - - am.addAttribute(SMOARMAttributes.getQueuingSystemDef().create(cluster.getLocalResourceManagerType())); - am.addAttribute(SMOARMAttributes.getAcceptsActivitiesDef().create(cluster.isIsAcceptingNewActivities())); - am.addAttribute(SMOARMAttributes.getCommonNameDef().create(cluster.getCommonName())); - - eam.setAttributeManager(rs, am); - final IRuntimeRMChangeEvent irrmce = eventFactory.newRuntimeRMChangeEvent(eam); - fireRuntimeRMChangeEvent(irrmce); - } - - } - - public void stopEvents() throws CoreException { - } - - /** - * Called by Eclipse when the job is to be submitted. - * - * @param subId - * - eclipse submission ID. {@link SMOAResourceManager} needs - * this to inform Eclipse that the job has been submitted. - */ - public void submitJob(String subId, ILaunchConfiguration configuration, String mode) throws CoreException { - - AttributeManager attrMgr = new AttributeManager(getAttributes(configuration, mode).toArray(new IAttribute<?, ?, ?>[0])); - - attrMgr.addAttribute(JobAttributes.getSubIdAttributeDefinition().create(subId)); - - final RangeSet rs = new RangeSet(nextJobNumber); - nextJobNumber++; - final ElementAttributeManager eam = new ElementAttributeManager(); - eam.setAttributeManager(rs, attrMgr); - - final IRuntimeNewJobEvent irnje = eventFactory.newRuntimeNewJobEvent("0", eam); //$NON-NLS-1$ - fireRuntimeNewJobEvent(irnje); - - final Exception e = jobSbmissionErrors.remove(subId); - if (e != null) { - throw new CoreException(new Status(IStatus.ERROR, SMOACoreActivator.PLUGIN_ID, e.getLocalizedMessage(), e)); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rtsystem.IControlSystem#terminateJob(java.lang.String) - */ - public void terminateJob(String jobId) throws CoreException { - } - - /** - * Change attributes of a job - * - * @param jobID - * @param changedAttrMgr - */ - public void changeJob(String jobID, AttributeManager changedAttrMgr) { - AttributeManager attrMgr = new AttributeManager(); - attrMgr.addAttributes(changedAttrMgr.getAttributes()); - ElementAttributeManager elementAttrs = new ElementAttributeManager(); - elementAttrs.setAttributeManager(new RangeSet(jobID), attrMgr); - IRuntimeJobChangeEvent event = eventFactory.newRuntimeJobChangeEvent(elementAttrs); - fireRuntimeJobChangeEvent(event); - } - - /** - * Convert launch configuration attributes to PTP attributes - */ - private List<IAttribute<?, ?, ?>> getAttributes(ILaunchConfiguration configuration, String mode) throws CoreException { - List<IAttribute<?, ?, ?>> attrs = new ArrayList<IAttribute<?, ?, ?>>(); - - /* - * Collect attributes from Application tab - */ - String exePath = configuration.getAttribute(IPTPLaunchConfigurationConstants.ATTR_EXECUTABLE_PATH, (String) null); - if (exePath != null) { - IPath programPath = new Path(exePath); - attrs.add(JobAttributes.getExecutableNameAttributeDefinition().create(programPath.lastSegment())); - - String path = programPath.removeLastSegments(1).toString(); - if (path != null) { - attrs.add(JobAttributes.getExecutablePathAttributeDefinition().create(path)); - } - } - - /* - * Collect attributes from Arguments tab - */ - String wd = configuration.getAttribute(IPTPLaunchConfigurationConstants.ATTR_WORKING_DIR, (String) null); - if (wd != null) { - attrs.add(JobAttributes.getWorkingDirectoryAttributeDefinition().create(wd)); - } - - String[] args = getProgramArguments(configuration, IPTPLaunchConfigurationConstants.ATTR_ARGUMENTS); - if (args != null) { - attrs.add(JobAttributes.getProgramArgumentsAttributeDefinition().create(args)); - } - - /* - * Collect attributes from Environment tab - */ - String[] envArr = getEnvironment(configuration); - if (envArr != null) { - attrs.add(JobAttributes.getEnvironmentAttributeDefinition().create(envArr)); - } - - /* - * Collect attributes from Debugger tab if this is a debug launch - */ - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - boolean stopInMainFlag = configuration.getAttribute(IPTPLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false); - attrs.add(JobAttributes.getDebuggerStopInMainFlagAttributeDefinition().create(Boolean.valueOf(stopInMainFlag))); - - attrs.add(JobAttributes.getDebugFlagAttributeDefinition().create(Boolean.TRUE)); - - args = getProgramArguments(configuration, IPTPLaunchConfigurationConstants.ATTR_DEBUGGER_ARGS); - if (args != null) { - attrs.add(JobAttributes.getDebuggerArgumentsAttributeDefinition().create(args)); - } - - String dbgExePath = configuration.getAttribute(IPTPLaunchConfigurationConstants.ATTR_DEBUGGER_EXECUTABLE_PATH, - (String) null); - if (dbgExePath != null) { - IPath path = new Path(dbgExePath); - attrs.add(JobAttributes.getDebuggerExecutableNameAttributeDefinition().create(path.lastSegment())); - attrs.add(JobAttributes.getDebuggerExecutablePathAttributeDefinition() - .create(path.removeLastSegments(1).toString())); - } - } - - /* - * PTP launched this job - */ - attrs.add(JobAttributes.getLaunchedByPTPFlagAttributeDefinition().create(Boolean.valueOf(true))); - - return attrs; - } - - /** - * Get environment to append - * - * @param configuration - * @return - * @throws CoreException - */ - private String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException { - Map<?, ?> defaultEnv = null; - Map<?, ?> configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, defaultEnv); - if (configEnv == null) { - return null; - } - - List<String> strings = new ArrayList<String>(configEnv.size()); - Iterator<?> iter = configEnv.entrySet().iterator(); - while (iter.hasNext()) { - Entry<?, ?> entry = (Entry<?, ?>) iter.next(); - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); - strings.add(key + "=" + value); //$NON-NLS-1$ - - } - return strings.toArray(new String[strings.size()]); - } - - /** - * Convert application arguments to an array of strings. - * - * @param configuration - * launch configuration - * @return array of strings containing the program arguments - * @throws CoreException - */ - private String[] getProgramArguments(ILaunchConfiguration configuration, String attrName) throws CoreException { - String temp = configuration.getAttribute(attrName, (String) null); - if (temp != null && temp.length() > 0) { - ArgumentParser ap = new ArgumentParser(temp); - List<String> args = ap.getTokenList(); - if (args != null) { - return args.toArray(new String[args.size()]); - } - } - return new String[0]; - } - - /** - * Initialize the attribute manager. This is called each time the runtime is - * started. - */ - private void initialize() { - attrMgr.clear(); - attrMgr.setAttributeDefinitions(ElementAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(ErrorAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(FilterAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(JobAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(MachineAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(MessageAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(NodeAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(ProcessAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(QueueAttributes.getDefaultAttributeDefinitions()); - attrMgr.setAttributeDefinitions(ResourceManagerAttributes.getDefaultAttributeDefinitions()); - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystemFactory.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystemFactory.java deleted file mode 100644 index 7f1b23df0..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/rtsystem/SMOARuntimeSystemFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 IBM Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.ptp.rm.smoa.core.rtsystem; - -import org.eclipse.ptp.core.elements.IPResourceManager; -import org.eclipse.ptp.rm.smoa.core.SMOAConfiguration; -import org.eclipse.ptp.rmsystem.IResourceManager; -import org.eclipse.ptp.rtsystem.IRuntimeSystem; -import org.eclipse.ptp.rtsystem.IRuntimeSystemFactory; - -public class SMOARuntimeSystemFactory implements IRuntimeSystemFactory { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ptp.rtsystem.IRuntimeSystemFactory#create(org.eclipse.ptp - * .rmsystem.IResourceManager) - */ - public IRuntimeSystem create(IResourceManager rm) { - SMOAConfiguration config = (SMOAConfiguration) rm.getConfiguration(); - IPResourceManager prm = (IPResourceManager) rm.getAdapter(IPResourceManager.class); - return new SMOARuntimeSystem(config, prm.getID()); - } -} diff --git a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/util/NotifyShell.java b/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/util/NotifyShell.java deleted file mode 100644 index 5afc35242..000000000 --- a/rms/org.eclipse.ptp.rm.smoa.core/src/org/eclipse/ptp/rm/smoa/core/util/NotifyShell.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Poznan Supercomputing and Networking Center - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Jan Konczak (PSNC) - initial implementation - ******************************************************************************/ - -package org.eclipse.ptp.rm.smoa.core.util; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -/** - * Class implementing a dialog independent to GUI actions, and not modal one. - * (Java's MessageBox has no ability to be non-modal) - */ - -public class NotifyShell { - - /** - * Open a non-modal hint-like dialog - */ - public static void open(final String title, final String message) { - - assert (title != null || message != null); - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - - final Shell s = new Shell(SWT.SHELL_TRIM | SWT.ON_TOP); - final GridLayout layout = new GridLayout(); - s.setLayout(layout); - s.setLocation(10, 10); - - // Title - if (title != null) { - final Label t = new Label(s, SWT.WRAP); - t.setText(title); - final FontData fd = t.getFont().getFontData()[0]; - fd.setStyle(fd.getStyle() | SWT.BOLD); - t.setFont(new Font(t.getDisplay(), fd)); - t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - // Message - if (message != null) { - final Label msg = new Label(s, SWT.WRAP); - msg.setLayoutData(new GridData(GridData.FILL_BOTH)); - msg.setText(message); - } - - // add button for closing - final Button ok = new Button(s, SWT.PUSH); - ok.setText("Ok"); //$NON-NLS-1$ - ok.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - ok.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - s.close(); - } - }); - - // layout properly - s.pack(); - - // correct if too wide - final int newX = Math.min(s.getSize().x, s.getDisplay() - .getClientArea().width - 20); - if (newX != s.getSize().x) { - s.setSize(newX, s.computeSize(newX, SWT.DEFAULT).y); - } - - // show - s.setVisible(true); - } - }); - } - - private NotifyShell() { - } -} |