Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 60396 Details for
Bug 136985
Need external APIs for Caspian for execution internals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch #1
patch_05.txt (text/plain), 446.54 KB, created by
Samson Wai
on 2007-03-07 15:13:53 EST
(
hide
)
Description:
Patch #1
Filename:
MIME Type:
Creator:
Samson Wai
Created:
2007-03-07 15:13:53 EST
Size:
446.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.execution >Index: .classpath >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.hyades.execution/.classpath,v >retrieving revision 1.9 >diff -u -r1.9 .classpath >--- .classpath 8 Mar 2006 17:30:57 -0000 1.9 >+++ .classpath 7 Mar 2007 20:06:10 -0000 >@@ -7,6 +7,7 @@ > <classpathentry kind="src" path="src-automation-client"/> > <classpathentry kind="src" path="src-automation-core"/> > <classpathentry kind="src" path="src-automation-server"/> >+ <classpathentry kind="src" path="src-local-public"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> > <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> > <accessrules> >Index: build.properties >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.hyades.execution/build.properties,v >retrieving revision 1.21 >diff -u -r1.21 build.properties >--- build.properties 11 May 2006 18:18:32 -0000 1.21 >+++ build.properties 7 Mar 2007 20:06:10 -0000 >@@ -25,7 +25,8 @@ > config.jar > source.hexcore.jar = src-core/ > output.hexcore.jar = bin/ >-source.hexl.jar = src-local/ >+source.hexl.jar = src-local/,\ >+ src-local-public/ > output.hexl.jar = bin/ > source.hexr.jar = src-remote/ > output.hexr.jar = bin/ >Index: src-local-public/org/eclipse/hyades/execution/local/common/PropertyListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/PropertyListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/PropertyListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/PropertyListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,111 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: PropertyListCommand.java,v 1.6 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.util.Vector; >+ >+public class PropertyListCommand extends CommandElement implements Constants { >+ private int size = 0; >+ private Vector names = new Vector(); >+ private Vector types = new Vector(); >+ private Vector values = new Vector(); >+ >+ public PropertyListCommand() { >+ super(); >+ _tag = RA_PROPERTY_LIST; >+ } >+ >+ public int getPropertyListLength() { >+ return size; >+ } >+ >+ public SetNVPairCommand[] getPropertyListValues() { >+ SetNVPairCommand[] results = new SetNVPairCommand[size]; >+ for (int i = 0; i < size; i++) { >+ results[i] = new SetNVPairCommand(); >+ results[i].setName(((RAString) names.elementAt(i)).getData()); >+ results[i].setType(((RAString) types.elementAt(i)).getData()); >+ results[i].setValue(((RAString) values.elementAt(i)).getData()); >+ } >+ return results; >+ } >+ >+ public void addPropertyListValue(String name, String type, String value) { >+ RAString rName = new RAString(name); >+ RAString rType = new RAString(type); >+ RAString rValue = new RAString(value); >+ >+ names.add(rName); >+ types.add(rType); >+ values.add(rValue); >+ >+ /* >+ * Bug 116585: PropertyListCommand does not work for IAC >+ */ >+ size++; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ // Read the number of entries >+ size = (int) Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ // Read the name, type, value entries >+ for (int i = 0; i < size; i++) { >+ RAString name = new RAString(""); >+ RAString type = new RAString(""); >+ RAString value = new RAString(""); >+ current = Message.readRAStringFromBuffer(buffer, current, name); >+ current = Message.readRAStringFromBuffer(buffer, current, type); >+ current = Message.readRAStringFromBuffer(buffer, current, value); >+ names.addElement(name); >+ types.addElement(type); >+ values.addElement(value); >+ } >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ >+ /* Names */ >+ current = Message.writeRALongToBuffer(buffer, current, size); >+ for (int i = 0; i < size; i++) { >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) names.elementAt(i))); >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) types.elementAt(i))); >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) values.elementAt(i))); >+ } >+ >+ return current; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // entry size >+ for (int i = 0; i < size; i++) { >+ size += ((RAString) names.elementAt(i)).getSize(); >+ size += ((RAString) types.elementAt(i)).getSize(); >+ size += ((RAString) values.elementAt(i)).getSize(); >+ } >+ >+ return size; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementMessage.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementMessage.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementMessage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementMessage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AcknowledgementMessage.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AcknowledgementMessage extends Message { >+ >+ /** >+ * AcknowledgementMessage constructor comment. >+ */ >+ public AcknowledgementMessage() { >+ super(); >+ _type = RA_ACKNOWLEDGEMENT_MESSAGE; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int length) { >+ return super.readFromBuffer(buffer, length); >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ return super.writeToBuffer(buffer, offset); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Agent.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Agent.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Agent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Agent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,162 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Agent.java,v 1.4 2005/09/27 20:31:58 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import org.eclipse.hyades.execution.local.common.CustomCommand; >+import org.eclipse.hyades.execution.local.common.DataProcessor; >+ >+public interface Agent { >+ >+ /** >+ * Add a listener that will inform you when this Agent becomes active/inactive. >+ * >+ * @see AgentListener >+ */ >+ void addAgentListener(AgentListener listener); >+ >+ /** >+ * Remove a listener previously added with addAgentListener. >+ * >+ * @see AgentListener >+ */ >+ void removeAgentListener(AgentListener listener); >+ >+ /** >+ * Get the process which this agent is a member of. >+ * >+ * @return the Process if it exists, null otherwise. >+ */ >+ Process getProcess(); >+ >+ void setProcess(Process p); >+ >+ /** >+ * If autoAttach is set, this is like registering an interest in this agent. It may not exist yet within the process, but you want to be attached to the agent as soon as it becomes active. >+ */ >+ boolean isAutoAttach(); >+ >+ void setAutoAttach(boolean auto); >+ >+ /** >+ * Attach to the agent. >+ */ >+ void attach() throws InactiveAgentException, InactiveProcessException; >+ >+ /** >+ * Detach from the agent. >+ */ >+ void detach() throws InactiveAgentException, InactiveProcessException; >+ >+ /** >+ * Retrieve the type name of this agent. >+ * >+ * @return the type of the agent if known, null otherwise. >+ */ >+ String getType(); >+ >+ void setType(String type); >+ >+ /** >+ * Retrieve the name of this agent. >+ * >+ * @return the name of the agent if known, null otherwise. >+ */ >+ String getName(); >+ >+ void setName(String name); >+ >+ /** >+ * Retrieve the UUID of this agent. >+ * >+ * @return the uuid of the agent if it is known, null otherwise. >+ */ >+ String getUUID(); >+ >+ void setUUID(String uuid); >+ >+ /** >+ * Determine whether this agent is currently active. >+ */ >+ boolean isActive(); >+ >+ void setActive(boolean isActive); >+ >+ /** >+ * Determine if this agent is currently being monitored. >+ */ >+ boolean isMonitored(); >+ >+ void setMonitored(boolean isMonitored); >+ >+ /** >+ * Determine is this agent is currently attached to a client. >+ */ >+ boolean isAttached(); >+ >+ boolean isAttached(boolean remote); // Bug 54376 >+ >+ void setAttached(boolean isAttached); >+ >+ /** >+ * Start monitoring the data output of this agent using the specified DataProcessor. You must be attached to the agent before you can start monitoring it. >+ */ >+ void startMonitoring(DataProcessor processor) throws InactiveAgentException; >+ >+ /** >+ * Stop monitoring this agent. >+ */ >+ void stopMonitoring() throws InactiveAgentException; >+ >+ /** >+ * Set the configuration for the agent. >+ */ >+ void setConfiguration(AgentConfiguration config); >+ >+ /** >+ * Get the configuration object for this agent. >+ * >+ * @return the AgentConfiguration if it exists, null otherwise. >+ */ >+ AgentConfiguration getConfiguration(); >+ >+ /** >+ * Publish's the AgentConfiguration to an active agent >+ */ >+ void publishConfiguration() throws InactiveAgentException; >+ >+ /** >+ * Send a custom command to the agent for processing. >+ */ >+ void invokeCustomCommand(CustomCommand command) throws InactiveAgentException; >+ >+ /** >+ * Determine if this agent is sending data to a profiling file >+ */ >+ public boolean isToProfileFile(); >+ >+ /** >+ * Get the fully quality path of profiling file >+ * >+ * @return String >+ */ >+ public String getProfileFile(); >+ >+ /** >+ * Set the fully quality path of profiling file >+ * >+ * @param _profileFile >+ * The _profileFile to set >+ */ >+ public void setProfileFile(String _profileFile); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/security/UntrustedAgentControllerException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/UntrustedAgentControllerException.java >diff -N src-local-public/org/eclipse/hyades/execution/security/UntrustedAgentControllerException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/UntrustedAgentControllerException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: UntrustedAgentControllerException.java,v 1.4 2005/09/13 16:46:21 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import org.eclipse.hyades.execution.local.control.AgentControllerUnavailableException; >+ >+public class UntrustedAgentControllerException extends AgentControllerUnavailableException { >+ >+ private static final long serialVersionUID = 3690196538207122739L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/CommandElement.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/CommandElement.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/CommandElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/CommandElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: CommandElement.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public abstract class CommandElement implements Constants { >+ >+ protected long _tag = 0; >+ protected long _context = 0; >+ >+ public CommandElement() { >+ super(); >+ } >+ >+ /** >+ * Return the context of this command element >+ * >+ * @return context >+ */ >+ public long getContext() { >+ return _context; >+ } >+ >+ /** >+ * Return the size of this command in number of bytes >+ * >+ * @return size >+ */ >+ public int getSize() { >+ return 2 * sizeofLong; >+ } >+ >+ /** >+ * Return the command tag >+ * >+ * @return tag >+ */ >+ public long getTag() { >+ return _tag; >+ } >+ >+ /** >+ * Construct the command by reading the buffer >+ * >+ * @param buffer >+ * Buffer containing serialized command >+ * @param offset >+ * Start position for reading >+ * @return >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ /* >+ * Do not need to read the tag since it is already read before coming in >+ * here >+ */ >+ int current = offset; >+ _context = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ return current; >+ } >+ >+ /** >+ * Set the command's context >+ * >+ * @param context >+ */ >+ public void setContext(long context) { >+ _context = context; >+ } >+ >+ /** >+ * Serialize the command into the byte buffer >+ * >+ * @param buffer >+ * Buffer containing serialized command >+ * @param offset >+ * Start position for reading >+ * @return >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = Message.writeRALongToBuffer(buffer, current, _tag); >+ current = Message.writeRALongToBuffer(buffer, current, _context); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/NodeFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/NodeFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/NodeFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/NodeFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,212 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: NodeFactory.java,v 1.5 2006/11/07 00:30:59 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.net.InetAddress; >+import java.net.UnknownHostException; >+import java.security.Principal; >+import java.util.Hashtable; >+ >+import org.eclipse.hyades.execution.security.DuplicateUserException; >+import org.eclipse.hyades.execution.security.User; >+ >+/** >+ * A factory for creating Nodes. Nodes can be specified by either name or InetAddress. Each Node is treated as a singleton and attempts to create a Node that already exists will return the same Node instance that already existed. >+ */ >+public class NodeFactory { >+ private static String _hostname = "localhost"; >+ private static Hashtable _servers = new Hashtable(); >+ >+ // static { >+ // try { >+ // _hostname = InetAddress.getLocalHost().getHostName(); >+ // _servers.put(_hostname, createNode(InetAddress.getLocalHost())); >+ // } >+ // catch(UnknownHostException e) { >+ // /* We ignore this here and throw the error >+ // when getLocalHost is called later. >+ // */ >+ // } >+ // } >+ >+ /** >+ * Create a Node for the suplied hostname. Nodes are are intended to be singletons in this application so if the Node exists it will be returned. >+ */ >+ public static Node createNode(String hostname) throws UnknownHostException { >+ try { >+ return createNode(hostname, null); >+ } catch (DuplicateUserException e) { >+ return containsNode(hostname, null); >+ } >+ >+ } >+ >+ public static Node createNode(String hostname, Principal principal) throws UnknownHostException, DuplicateUserException { >+ Node result = containsNode(hostname, principal); >+ if (result == null) { >+ InetAddress addr = InetAddress.getByName(hostname); >+ return addNode(hostname, addr, principal); >+ } >+ throw new DuplicateUserException(); >+ } >+ >+ /** >+ * Create a Node for the suplied InetAddress. Nodes are are intended to be singletons in this application so if the Node exists it will be returned. >+ */ >+ public static Node createNode(InetAddress address) throws UnknownHostException { >+ return createNode(address, null); >+ } >+ >+ public static Node createNode(InetAddress address, Principal principal) throws UnknownHostException { >+ String hostname = address.getHostName(); >+ Node result = containsNode(hostname, principal); >+ if (result == null) { >+ result = addNode(hostname, address, principal); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns the node that represents the local host. >+ * >+ * @deprecated - use getLocalHost(User user) >+ */ >+ public static Node getLocalHost() throws UnknownHostException { >+ return getLocalHost(null); >+ } >+ >+ public static Node getLocalHost(Principal principal) throws UnknownHostException { >+ /* The localhost is always in the first slot of the servers table */ >+ Node localNode = null; >+ synchronized (_servers) { >+ localNode = (Node) _servers.get(_hostname); >+ if (localNode == null) { >+ throw new UnknownHostException(); >+ } >+ } >+ return localNode; >+ } >+ >+ public static void addNode(Node node) { >+ String nodeName = node.getName(); >+ synchronized (_servers) { >+ if (!_servers.containsKey(nodeName)) { >+ _servers.put(nodeName, node); >+ } >+ } >+ } >+ >+ private static Node addNode(String name, InetAddress addr, Principal principal) { >+ if (name == null) { >+ return null; >+ } >+ >+ if (name.equals("localhost")) { >+ try { >+ name = InetAddress.getLocalHost().getHostName(); >+ InetAddress[] addrs = InetAddress.getAllByName(name); >+ addr = addrs[0]; >+ } catch (UnknownHostException e) { >+ /* We can ignore this */ >+ } >+ } >+ >+ synchronized (_servers) { >+ // Check if node already exist >+ if (_servers.containsKey(name)) { >+ Node existingNode = (Node) _servers.get(name); >+ // Update the principal >+ if (principal instanceof User) { >+ existingNode.setUser((User) principal); >+ } else if (principal instanceof Application) { >+ existingNode.setApplication((Application) principal); >+ } >+ return existingNode; >+ } else { >+ Node newNode = new NodeImpl(name, addr); >+ if (principal instanceof User) { >+ newNode.setUser((User) principal); >+ } else if (principal instanceof Application) { >+ newNode.setApplication((Application) principal); >+ } >+ addNode(newNode); >+ return newNode; >+ } >+ } >+ } >+ >+ /** >+ * Searches the Node list based upon the hostname. >+ * >+ * @return the Node if it exists, null otherwise. >+ */ >+ private static Node containsNode(String name, Principal principal) { >+ Node node = null; >+ >+ if (name == null) { >+ return null; >+ } >+ >+ synchronized (_servers) { >+ /* If this is "localhost" try and resolve its real name first */ >+ if (name.equals("localhost")) { >+ try { >+ name = InetAddress.getLocalHost().getHostName(); >+ } catch (UnknownHostException e) { >+ /* We can ignore this */ >+ } >+ } >+ >+ if (_servers.containsKey(name)) { >+ node = (Node) _servers.get(name); >+ if (principal == null) { >+ // Node is the right one since no principal is supplied >+ } else if ((principal instanceof User) && (node.getUser() != null)) { >+ if (principal.getName().equals(node.getUser().getName())) { >+ // Node is the right one since no principal is supplied >+ } else { >+ node = null; >+ } >+ } else if ((principal instanceof Application) && (node.getApplication() != null)) { >+ if (principal.getName().equals(node.getApplication().getName())) { >+ // Node is the right one since no principal is supplied >+ } else { >+ node = null; >+ } >+ } >+ } >+ } >+ >+ return node; >+ } >+ >+ /** >+ * Searches the Node list based upon the InetAddress. >+ * >+ * @return the Node if it exists, null otherwise. >+ */ >+ public static Node getNode(InetAddress addr) { >+ return getNode(addr, null); >+ } >+ >+ public static Node getNode(InetAddress addr, Principal principal) { >+ /* Resolve the name and delegate */ >+ return containsNode(addr.getHostName(), principal); >+ } >+ >+ public static Node getNode(String name, Principal principal) throws UnknownHostException { >+ /* Resolve the name and delegate */ >+ return getNode(InetAddress.getByName(name), principal); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/security/LoginFailedException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/LoginFailedException.java >diff -N src-local-public/org/eclipse/hyades/execution/security/LoginFailedException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/LoginFailedException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: LoginFailedException.java,v 1.3 2005/05/01 16:59:32 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import org.eclipse.hyades.execution.local.control.AgentControllerUnavailableException; >+ >+public class LoginFailedException extends AgentControllerUnavailableException { >+ >+ private static final long serialVersionUID = 4048796749525233976L; >+ private long _port; >+ >+ public LoginFailedException(long port) { >+ _port = port; >+ } >+ >+ public long getSecurePort() { >+ return _port; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/DataProcessor.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/DataProcessor.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/DataProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/DataProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DataProcessor.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import org.eclipse.hyades.execution.core.IDataProcessor; >+ >+public interface DataProcessor extends IDataProcessor { >+} >Index: src-local-public/org/eclipse/hyades/execution/security/AuthenticationListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/AuthenticationListener.java >diff -N src-local-public/org/eclipse/hyades/execution/security/AuthenticationListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/AuthenticationListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AuthenticationListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import org.eclipse.hyades.execution.local.control.Connection; >+ >+public interface AuthenticationListener { >+ >+ void authenticationRequired(Connection connection); >+ >+ void authenticationSuccessful(Connection connection); >+ >+ void authenticationFailed(Connection connection); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentRequestMonitorCommand.java,v 1.1 2006/03/06 19:49:40 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentRequestMonitorCommand extends MonitorPeerRequestCommand { >+ >+ public AgentRequestMonitorCommand() { >+ super(); >+ _tag = RA_AGENT_REQUEST_MONITOR; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/RegisterAgentInterestCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/RegisterAgentInterestCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/RegisterAgentInterestCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/RegisterAgentInterestCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: RegisterAgentInterestCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class RegisterAgentInterestCommand extends SimpleAgentInfoCommand { >+ >+ /** >+ * >+ */ >+ public RegisterAgentInterestCommand() { >+ super(); >+ _tag = RA_REGISTER_AGENT_NOTIFICATION; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ProcessFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ProcessFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ProcessFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ProcessFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessFactory.java,v 1.3 2005/09/27 20:31:57 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class ProcessFactory { >+ >+ public static Process createProcess(Node node) { >+ Process process = new ProcessImpl(node); >+ if (node instanceof NodeImpl) { >+ process.addProcessListener(((NodeImpl) node).getProcessListener()); >+ } >+ return process; >+ } >+ >+ public static Process createProcess(Node node, long pid) { >+ Process process = new ProcessImpl(node, pid); >+ if (node instanceof NodeImpl) { >+ process.addProcessListener(((NodeImpl) node).getProcessListener()); >+ } >+ return process; >+ } >+ >+ public static Process createProcess(Node node, String executable) { >+ Process process = new ProcessImpl(node, executable); >+ if (node instanceof NodeImpl) { >+ process.addProcessListener(((NodeImpl) node).getProcessListener()); >+ } >+ return process; >+ } >+ >+ public static Process createProcess(Node node, String executable, long pid) { >+ Process process = new ProcessImpl(node, executable, pid); >+ if (node instanceof NodeImpl) { >+ process.addProcessListener(((NodeImpl) node).getProcessListener()); >+ } >+ return process; >+ } >+ >+ public static Process createProcess(Node node, String executable, String parameters) { >+ Process process = new ProcessImpl(node, executable, parameters); >+ if (node instanceof NodeImpl) { >+ process.addProcessListener(((NodeImpl) node).getProcessListener()); >+ } >+ return process; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentDetailsCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentDetailsCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentDetailsCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentDetailsCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: QueryAgentDetailsCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class QueryAgentDetailsCommand extends SimpleAgentInfoCommand implements Constants { >+ >+ public QueryAgentDetailsCommand() { >+ super(); >+ _tag = RA_QUERY_AGENT_DETAILS; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ConsoleInfoCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ConsoleInfoCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ConsoleInfoCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ConsoleInfoCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ConsoleInfoCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.InputStream; >+import java.io.OutputStream; >+ >+public class ConsoleInfoCommand extends SimpleProcessCommand { >+ private InputStream _stdout; >+ private InputStream _stderr; >+ private OutputStream _stdin; >+ >+ public ConsoleInfoCommand(long pid, InputStream stdout, InputStream stderr, OutputStream stdin) { >+ _tag = Constants.RA_CONSOLE_INFO; >+ _stdout = stdout; >+ _stderr = stderr; >+ _stdin = stdin; >+ super.setProcessId(pid); >+ } >+ >+ public long getProcessId() { >+ return super.getProcessId(); >+ } >+ >+ public InputStream getStdOut() { >+ return _stdout; >+ } >+ >+ public InputStream getStdErr() { >+ return _stderr; >+ } >+ >+ public OutputStream getStdIn() { >+ return _stdin; >+ } >+ >+ public int getSize() { >+ return 0; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ return 0; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ return 0; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/MessageOverflowException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/MessageOverflowException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/MessageOverflowException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/MessageOverflowException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: MessageOverflowException.java,v 1.4 2005/10/08 14:28:53 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class MessageOverflowException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 1648853064662621578L; >+ >+ /** >+ * MessageOverflowException constructor comment. >+ */ >+ public MessageOverflowException() { >+ super(); >+ } >+ >+ /** >+ * MessageOverflowException constructor comment. >+ * >+ * @param s >+ * java.lang.String >+ */ >+ public MessageOverflowException(String s) { >+ super(s); >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/security/DuplicateUserException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/DuplicateUserException.java >diff -N src-local-public/org/eclipse/hyades/execution/security/DuplicateUserException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/DuplicateUserException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DuplicateUserException.java,v 1.3 2005/05/01 16:59:32 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import org.eclipse.hyades.execution.core.DaemonConnectException; >+ >+public class DuplicateUserException extends DaemonConnectException { >+ >+ private static final long serialVersionUID = 3979264742185579057L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestPortCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestPortCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestPortCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestPortCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,53 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: MonitorPeerRequestPortCommand.java,v 1.3 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class MonitorPeerRequestPortCommand extends MonitorPeerRequestCommand { >+ private long _peerPort = 10002; >+ private long _targetPort = 10002; >+ >+ public MonitorPeerRequestPortCommand() { >+ super(); >+ _tag = RA_CONTROLLER_REQUEST_MONITOR_PORT; >+ } >+ >+ public int getSize() { >+ return super.getSize() + (2 * sizeofLong); >+ } >+ >+ public long getPeerPort() { >+ return _peerPort; >+ } >+ >+ public long getTargetPort() { >+ return _targetPort; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ >+ _targetPort = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ _peerPort = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRALongToBuffer(buffer, current, _targetPort); >+ current = Message.writeRALongToBuffer(buffer, current, _peerPort); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ControlMessage.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ControlMessage.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ControlMessage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ControlMessage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,391 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ControlMessage.java,v 1.8 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ControlMessage extends Message { >+ >+ CommandElement[] _entries = null; >+ >+ /* The length field */ >+ long _length; >+ >+ /* The authentication key */ >+ protected RAString _key = new RAString(""); >+ >+ /** >+ * ControlMessage constructor comment. >+ */ >+ public ControlMessage() { >+ super(); >+ _type = RA_CONTROL_MESSAGE; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 4:35:08 PM) >+ * >+ * @param command >+ * com.ibm.jvmpi.common.CommandEntryElement >+ */ >+ public void appendCommand(CommandElement command) { >+ if (_entries == null) { >+ _entries = new CommandElement[1]; >+ _entries[0] = command; >+ return; >+ } >+ synchronized (_entries) { >+ // if(this.getSize()+command.getSize() >= MAX_MESSAGE_LENGTH) >+ // throw new MessageOverflowException(); >+ >+ CommandElement[] _oldElements = _entries; >+ _entries = new CommandElement[_oldElements.length + 1]; >+ for (int i = 0; i < _oldElements.length; i++) { >+ _entries[i] = _oldElements[i]; >+ } >+ _entries[_oldElements.length] = command; >+ } >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 2:35:25 PM) >+ * >+ * @return com.ibm.jvmpi.common.CommandEntryElement >+ * @param offset >+ * int >+ */ >+ public CommandElement getCommand(int offset) { >+ return _entries[offset]; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 6:40:36 PM) >+ * >+ * @return int >+ */ >+ public int getCommandCount() { >+ return _entries.length; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 5:57:46 >+ * PM) >+ */ >+ public RAString getKey() { >+ return _key; >+ } >+ >+ /* 185463 begin */ >+ /** >+ * Returns length of message read from message itself. Creation date: >+ * (09/27/00 5:57:46 PM) >+ */ >+ public long getLength() { >+ return _length; >+ } >+ >+ /* 185463 end */ >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 10:21:47 AM) >+ * >+ * @return short >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ /* The length field */ >+ size += sizeofLong; >+ /* Key size */ >+ size += (int) _key.getSize(); >+ >+ /* Area for the count */ >+ size += sizeofLong; >+ >+ /* The commands */ >+ >+ /* synchronized(_entries) { */ >+ for (int i = 0; i < _entries.length; i++) >+ size += _entries[i].getSize(); >+ /* } */ >+ return size; >+ } >+ >+ /** >+ * readFromBuffer - checks if the full message is contained in the buffer >+ * >+ * @param buffer >+ * data buffer to read from >+ * @param offset >+ * offset with the data buffer to start reading from >+ * @param length >+ * length of the data in the buffer >+ */ >+ public int readFromBuffer(byte[] buffer, int offset, int length) { >+ int current = super.readFromBuffer(buffer, offset); >+ >+ long msgLength = Message.readRALongFromBuffer(buffer, current); >+ >+ /* >+ * First check if the message length field is contained in the data >+ * buffer so it is assured to be a valid length value and then check if >+ * the full message is contained in the data remaining in the buffer >+ */ >+ if (current + sizeofLong > offset + length || msgLength > length) { >+ throw new ArrayIndexOutOfBoundsException("Not enough bytes in the buffer array"); >+ } >+ >+ return readFromBuffer(buffer, offset); >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ >+ _length = Message.readRALongFromBuffer(buffer, current); >+ if (_length > buffer.length) { >+ throw new ArrayIndexOutOfBoundsException("Not enough bytes in the buffer array"); >+ } >+ >+ current += sizeofLong; >+ /* authentication key */ >+ current = readRAStringFromBuffer(buffer, current, _key); >+ >+ /* How many commands are in this message */ >+ long count = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ _entries = new CommandElement[(int) count]; >+ >+ /* Read in each command */ >+ for (int i = 0; i < count; i++) { >+ long tag = Message.readRALongFromBuffer(buffer, current); >+ >+ current += sizeofLong; >+ CommandElement command = null; >+ switch ((int) tag) { >+ case (int) RA_AUTHENTICATE: // 0x01 >+ command = new AuthenticateCommand(); >+ current = ((AuthenticateCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AUTHENTICATION_FAILED: // 0x02 >+ command = new AuthenticationFailedCommand(); >+ current = ((AuthenticationFailedCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AUTHENTICATION_SUCCESSFUL: // 0x03 >+ command = new AuthenticationSuccessfulCommand(); >+ current = ((AuthenticationSuccessfulCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_SERVER_SECURITY_REQUIREMENTS: // 0x04 >+ command = new ServerSecurityInfoCommand(); >+ current = ((ServerSecurityInfoCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_LAUNCH_PROCESS: // 0x10 >+ command = new LaunchProcessCommand(); >+ current = ((LaunchProcessCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_QUERY_PROCESS_LIST: // 0x11 >+ command = new QueryProcessListCommand(); >+ current = ((QueryProcessListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_QUERY_AGENT_LIST: // 0x12 >+ command = new QueryAgentListCommand(); >+ current = ((QueryAgentListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_REGISTER_AGENT_NOTIFICATION: // 0x13 >+ command = new RegisterAgentInterestCommand(); >+ current = ((RegisterAgentInterestCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_ATTACH_TO_AGENT: // 0x14 >+ command = new AttachToAgentCommand(); >+ current = ((AttachToAgentCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_DETACH_FROM_AGENT: // 0x15 >+ command = new DetachFromAgentCommand(); >+ current = ((DetachFromAgentCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_START_MONITORING_AGENT_REMOTE: // 0x16 >+ command = new StartMonitoringRemoteAgentCommand(); >+ current = ((StartMonitoringRemoteAgentCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_START_MONITORING_AGENT_LOCAL: // 0x17 >+ command = new StartMonitoringLocalAgentCommand(); >+ current = ((StartMonitoringLocalAgentCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_STOP_MONITORING_AGENT: // 0x18 >+ command = new StopMonitorCommand(); >+ current = ((StopMonitorCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_SET_NAME_VALUE_PAIR: // 0x19 >+ command = new SetNVPairCommand(); >+ current = ((SetNVPairCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_CUSTOM_COMMAND: // 0x1A >+ command = new CustomCommand(); >+ current = ((CustomCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_KILL_PROCESS: // 0x1B >+ command = new KillProcessCommand(); >+ current = ((KillProcessCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_QUERY_AGENT_DETAILS: // 0x1C >+ command = new QueryAgentDetailsCommand(); >+ current = ((QueryAgentDetailsCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_BINARY_CUSTOM_COMMAND: // 0x1D >+ command = new BinaryCustomCommand(); >+ current = ((BinaryCustomCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_GET_PROPERTY_LIST: // 0x1E >+ command = new GetPropertyListCommand(); >+ current = ((GetPropertyListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_MANAGE_FILE: // 0x1F >+ command = new ManageFileCommand(); >+ current = ((ManageFileCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_PROCESS_LAUNCHED: // 0x20 >+ command = new ProcessLaunchedCommand(); >+ current = ((ProcessLaunchedCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_PROCESS_LIST: // 0x21 >+ command = new RegisteredProcessListCommand(); >+ current = ((RegisteredProcessListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_LIST: // 0x22 >+ command = new ActiveAgentListCommand(); >+ current = ((ActiveAgentListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_ACTIVE: // 0x23 >+ command = new AgentActiveCommand(); >+ current = ((AgentActiveCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_INACTIVE: // 0x24 >+ command = new AgentInactiveCommand(); >+ current = ((AgentInactiveCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_ERROR_STRING: // 0x25 >+ command = new ErrorCommand(); >+ current = ((ErrorCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_ATTACH_SUCCESSFUL: // 0x26 >+ break; // Not used >+ case (int) RA_ATTACH_FAILED: // 0x27 >+ break; // Not used >+ case (int) RA_AGENT_DETAILS: // 0x28 >+ command = new AgentDetailsCommand(); >+ current = ((AgentDetailsCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_PROCESS_EXITED: // 0x29 >+ command = new ProcessExitedCommand(); >+ current = ((ProcessExitedCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_PROPERTY_LIST: // 0x2A >+ command = new PropertyListCommand(); >+ current = ((PropertyListCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_QUERY_STATE: // 0x2B >+ command = new AgentQueryStateCommand(); >+ current = ((AgentQueryStateCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_ATTACHED: // 0x2C >+ command = new AgentAttachedCommand(); >+ current = ((AgentAttachedCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_DETACHED: // 0x2D >+ command = new AgentDetachedCommand(); >+ current = ((AgentDetachedCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_LOCAL_AGENT_ACTIVE: // 0x30 >+ break; // Not used >+ case (int) RA_AGENT_SCOPING_INFORMATION: // 0x31 >+ command = new AgentScopingInformationCommand(); >+ current = ((AgentScopingInformationCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_CONFIGURATION: // 0x32 >+ command = new AgentConfigurationCommand(); >+ current = ((AgentConfigurationCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_AGENT_CONTROLLER_AVAILABLE: // 0x50 >+ break; // Not used >+ case (int) RA_AGENT_CONTROLLER_UNAVAILABLE: // 0x51 >+ break; // Not used >+ case (int) RA_AGENT_REQUEST_MONITOR: // 0x61 >+ command = new AgentRequestMonitorCommand(); >+ current = ((AgentRequestMonitorCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_CONTROLLER_REQUEST_MONITOR: // 0x62 >+ command = new MonitorPeerRequestCommand(); >+ current = ((MonitorPeerRequestCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_PEER_UNREACHABLE: // 0x63 >+ command = new PeerUnreachableCommand(); >+ current = ((PeerUnreachableCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_CONTROLLER_MONITOR_PEER: // 0x64 >+ break; // Not used >+ case (int) RA_AGENT_REQUEST_MONITOR_PORT: // 0x65 >+ command = new AgentRequestMonitorPortCommand(); >+ current = ((AgentRequestMonitorPortCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_CONTROLLER_REQUEST_MONITOR_PORT: // 0x66 >+ command = new MonitorPeerRequestPortCommand(); >+ current = ((MonitorPeerRequestPortCommand) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_RESOURCE_LOCATION: // 0x70 >+ command = new ResourceLocation(); >+ current = ((ResourceLocation) command).readFromBuffer(buffer, current); >+ break; >+ case (int) RA_CONSOLE_INFO: // 0x80 >+ break; // Not serializable >+ } >+ /* Store the command in the array */ >+ _entries[i] = command; >+ >+ } >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 5:59:07 >+ * PM) >+ * >+ * @param key >+ * java.lang.String >+ */ >+ public void setKey(RAString key) { >+ _key = key; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ >+ /* Insert the length */ >+ _length = getSize(); >+ current = Message.writeRALongToBuffer(buffer, current, _length); >+ /* Insert the authentication key */ >+ current = writeRAStringToBuffer(buffer, current, _key); >+ >+ /* place the command count in the buffer */ >+ current = Message.writeRALongToBuffer(buffer, current, _entries.length); >+ >+ for (int i = 0; i < _entries.length; i++) { >+ current = _entries[i].writeToBuffer(buffer, current); >+ >+ } >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ProcessLaunchedCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ProcessLaunchedCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ProcessLaunchedCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ProcessLaunchedCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,177 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessLaunchedCommand.java,v 1.5 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.util.Vector; >+ >+public class ProcessLaunchedCommand extends DetailedProcessCommand { >+ >+ RAString _exe = new RAString(""); >+ RAString _args = new RAString(""); >+ Vector _environment = new Vector(); >+ >+ /** >+ * ProcessLaunchedCommand constructor comment. >+ */ >+ public ProcessLaunchedCommand() { >+ super(); >+ _tag = RA_PROCESS_LAUNCHED; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 7:42:56 PM) >+ * >+ * @param name >+ * java.lang.String >+ * @param value >+ * java.lang.String >+ */ >+ public void addEnvironmentVariable(String name, String value) { >+ _environment.addElement(new RAString(name + "=" + value)); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 12:59:18 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getArgs() { >+ if (_args != null) >+ return _args.getData(); >+ return null; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 9:02:18 AM) >+ * >+ * @return java.lang.String[] >+ */ >+ public String[] getEnvironment() { >+ String[] result = new String[_environment.size()]; >+ for (int i = 0; i < _environment.size(); i++) { >+ result[i] = ((RAString) (_environment.elementAt(i))).getData(); >+ } >+ >+ return result; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 8:58:33 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getExe() { >+ if (_exe != null) >+ return _exe.getData(); >+ >+ return null; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 1:00:36 PM) >+ * >+ * @return int >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ size += _exe.getSize(); >+ size += _args.getSize(); >+ >+ size += sizeofLong; >+ >+ for (int i = 0; i < _environment.size(); i++) { >+ size += ((RAString) _environment.elementAt(i)).getSize(); >+ } >+ >+ return size; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 10:20:50 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _exe); >+ current = Message.readRAStringFromBuffer(buffer, current, _args); >+ >+ long listLength = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ for (int i = 0; i < listLength; i++) { >+ RAString envVar = new RAString(""); >+ current = Message.readRAStringFromBuffer(buffer, current, envVar); >+ _environment.addElement(envVar); >+ } >+ >+ return current; >+ >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 1:00:01 PM) >+ * >+ * @param args >+ * java.lang.String >+ */ >+ public void setArgs(String args) { >+ _args = new RAString(args); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 8:58:07 PM) >+ * >+ * @param exe >+ * java.lang.String >+ */ >+ public void setExe(String exe) { >+ _exe = new RAString(exe); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (7/21/00 2:36:20 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ >+ public void setEnvironment(String[] env) { >+ if (env != null) { >+ int count = env.length; >+ for (int i = 0; i < count; i++) { >+ RAString entry = new RAString(env[i]); >+ _environment.add(entry); >+ } >+ } >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _exe); >+ current = Message.writeRAStringToBuffer(buffer, current, _args); >+ >+ current = Message.writeRALongToBuffer(buffer, current, _environment.size()); >+ >+ for (int i = 0; i < _environment.size(); i++) { >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) _environment.elementAt(i))); >+ } >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/LocalConsole.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/LocalConsole.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/LocalConsole.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/LocalConsole.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,287 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: LocalConsole.java,v 1.8 2006/04/26 19:59:16 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.OutputStream; >+import java.io.UnsupportedEncodingException; >+import java.net.InetAddress; >+import java.net.ServerSocket; >+import java.net.UnknownHostException; >+ >+public class LocalConsole extends Console { >+ private ConsoleOutReader _outReader = null; >+ private ConsoleErrReader _errReader = null; >+ private ConsoleWaitingThread _waitThread = null; >+ private DataProcessor _processor = null; >+ private boolean _done = false; >+ private InputStream _stdout; >+ private InputStream _stderr; >+ private OutputStream _stdin; >+ >+ private int _bytesWritten = 0; >+ >+ /* >+ * Allows the console threads to wait until the streams are established >+ */ >+ private Object _processor_lock = new Object(); >+ private Object _stdin_lock = new Object(); >+ private Object _stdout_lock = new Object(); >+ private Object _stderr_lock = new Object(); >+ >+ public LocalConsole() { >+ this("Local Console"); >+ } >+ >+ public LocalConsole(String name) { >+ super(name); >+ this.setDaemon(true); >+ } >+ >+ public LocalConsole(ThreadGroup group, String name) { >+ super(group, name); >+ this.setDaemon(true); >+ } >+ >+ private synchronized int getConsoleBytesWritten() { >+ return _bytesWritten; >+ } >+ >+ public long getIP() { >+ return 0; >+ } >+ >+ public long getPort() { >+ return 0; >+ } >+ >+ public ServerSocket getServerSocket() { >+ return null; >+ } >+ >+ public void run() { >+ _outReader = new ConsoleOutReader(); >+ _outReader.start(); >+ _errReader = new ConsoleErrReader(); >+ _errReader.start(); >+ _waitThread = new ConsoleWaitingThread(); >+ _waitThread.start(); >+ } >+ >+ public void start() { >+ run(); >+ } >+ >+ private synchronized void setConsoleBytesWritten(int bytes) { >+ _bytesWritten = bytes; >+ } >+ >+ public void setDataProcessor(DataProcessor processor) { >+ synchronized (_processor_lock) { >+ _processor = processor; >+ _processor_lock.notifyAll(); >+ } >+ } >+ >+ public void setStdOut(InputStream stdout) { >+ synchronized (_stdout_lock) { >+ _stdout = stdout; >+ _stdout_lock.notifyAll(); >+ } >+ } >+ >+ public void setStdErr(InputStream stderr) { >+ synchronized (_stderr_lock) { >+ _stderr = stderr; >+ _stderr_lock.notifyAll(); >+ } >+ } >+ >+ public void setStdIn(OutputStream stdin) { >+ synchronized (_stdin_lock) { >+ _stdin = stdin; >+ _stdin_lock.notifyAll(); >+ } >+ } >+ >+ public DataProcessor getDataProcessor() { >+ return _processor; >+ } >+ >+ public void write(String data) { >+ if (_stdin == null) { >+ synchronized (_stdin_lock) { >+ try { >+ _stdin_lock.wait(); >+ } catch (InterruptedException e) { >+ return; >+ } >+ } >+ } >+ >+ byte b[]; >+ try { >+ b = data.getBytes("UTF-8"); >+ } catch (UnsupportedEncodingException e) { >+ b = data.getBytes(); >+ } >+ >+ try { >+ _stdin.write(b); >+ _stdin.flush(); >+ } catch (IOException e) { >+ return; >+ } >+ } >+ >+ /* Closes this console */ >+ public void close() { >+ _done = true; >+ if (_outReader != null) { >+ _outReader.interrupt(); >+ } >+ if (_errReader != null) { >+ _errReader.interrupt(); >+ } >+ if (_waitThread != null) { >+ _waitThread.interrupt(); >+ } >+ } >+ >+ class ConsoleOutReader extends Thread { >+ private byte[] buffer = new byte[1024]; >+ >+ public ConsoleOutReader() { >+ setName("Console Output Reader"); >+ } >+ >+ public void run() { >+ synchronized (_stdout_lock) { >+ if (_stdout == null) { >+ try { >+ _stdout_lock.wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ >+ while (!_done) { >+ int byteRead = -1; >+ try { >+ byteRead = _stdout.read(buffer); >+ } catch (IOException e1) { >+ } >+ >+ if (byteRead == -1) { >+ _done = true; >+ } else { >+ try { >+ synchronized (_processor_lock) { >+ if (_processor == null) { >+ try { >+ _processor_lock.wait(30000); >+ } catch (InterruptedException e) { >+ } // 30 sec max? >+ } >+ if (_processor != null) { >+ _processor.incommingData(buffer, byteRead, InetAddress.getLocalHost()); >+ setConsoleBytesWritten(byteRead); >+ } else { >+ System.out.print(new String(buffer, 0, byteRead)); >+ } >+ } >+ } catch (UnknownHostException e) { >+ // Error handling console >+ } >+ } >+ } >+ } >+ } >+ >+ class ConsoleErrReader extends Thread { >+ private byte[] buffer = new byte[1024]; >+ >+ public ConsoleErrReader() { >+ setName("Console Error Reader"); >+ } >+ >+ public void run() { >+ synchronized (_stderr_lock) { >+ if (_stderr == null) { >+ try { >+ _stderr_lock.wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ >+ while (!_done) { >+ int byteRead = -1; >+ try { >+ byteRead = _stderr.read(buffer); >+ } catch (IOException e1) { >+ } >+ >+ if (byteRead == -1) { >+ _done = true; >+ } else { >+ try { >+ synchronized (_processor_lock) { >+ if (_processor == null) { >+ try { >+ _processor_lock.wait(30000); >+ } catch (InterruptedException e) { >+ } // 30 sec max? >+ } >+ if (_processor != null) { >+ _processor.incommingData(buffer, byteRead, InetAddress.getLocalHost()); >+ setConsoleBytesWritten(byteRead); >+ } else { >+ System.err.print(new String(buffer, 0, byteRead)); >+ } >+ } >+ } catch (UnknownHostException e) { >+ // Error handling console >+ } >+ } >+ } >+ } >+ } >+ >+ class ConsoleWaitingThread extends Thread { >+ public ConsoleWaitingThread() { >+ setName("Console Waiting Notification"); >+ } >+ >+ public void run() { >+ while (!_done) { >+ try { >+ sleep(3000); // 3 sec console polling >+ } catch (Exception e) { >+ } >+ >+ if (getConsoleBytesWritten() == 0) { >+ synchronized (_processor_lock) { >+ if (_processor != null) { >+ _processor.waitingForData(); >+ } >+ } >+ } else { >+ setConsoleBytesWritten(0); >+ } >+ } >+ } >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/NoSuchApplicationException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/NoSuchApplicationException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/NoSuchApplicationException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/NoSuchApplicationException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: NoSuchApplicationException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+/** >+ * @author rduggan >+ * >+ * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation. >+ */ >+public class NoSuchApplicationException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 3694219616735552248L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannelFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannelFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannelFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannelFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,96 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SocketChannelFactory.java,v 1.5 2006/10/30 18:25:55 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.hyades.execution.core.file.socket; >+ >+import java.io.IOException; >+import java.net.InetSocketAddress; >+import java.net.Socket; >+ >+/** >+ * Factory to create the local socket channel abstraction, this factory offers a default instance to use for normal unsecure socket establishment but other factories can be implemented that implement the socket channel factory interface and used where socket channel factories are applicable and required >+ * >+ * @author Scott E. Schneider >+ */ >+public class SocketChannelFactory implements ISocketChannelFactory { >+ >+ /** >+ * The default socket channel factory instance >+ */ >+ private static final ISocketChannelFactory factory; >+ >+ /** >+ * Create and store the singleton instance, not using on demand creation, always create on class load >+ */ >+ static { >+ factory = new SocketChannelFactory(); >+ } >+ >+ /** >+ * Default instance accessor method >+ * >+ * @return the default socket channel factory, another implementation is possible by implementing the socket channel factory interface >+ */ >+ public static ISocketChannelFactory getInstance() { >+ return SocketChannelFactory.factory; >+ } >+ >+ /** >+ * Limit instantiation to factory extenders >+ */ >+ protected SocketChannelFactory() { >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.hyades.execution.core.file.socket.ISocketChannelFactory#create(java.net.InetSocketAddress) >+ */ >+ public ISocketChannel create(InetSocketAddress address) throws IOException { >+ return this.create(address, 60000); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.hyades.execution.core.file.socket.ISocketChannelFactory#create(java.net.InetSocketAddress, int) >+ */ >+ public ISocketChannel create(InetSocketAddress address, int timeout) throws IOException { >+ java.nio.channels.SocketChannel socketChannel = java.nio.channels.SocketChannel.open(); >+ socketChannel.configureBlocking(true); >+ Socket socket = socketChannel.socket(); >+ socket.setSoTimeout(timeout); >+ socket.setTcpNoDelay(true); >+ socket.setReuseAddress(true); >+ socketChannel.connect(address); >+ return new SocketChannel(socketChannel); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.hyades.execution.core.file.ISocketChannelFactory#create(java.nio.channels.SocketChannel) >+ */ >+ public ISocketChannel create(java.nio.channels.SocketChannel realChannel) { >+ return new SocketChannel(realChannel); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.hyades.execution.core.file.ISocketChannelFactory#create(java.net.Socket) >+ */ >+ public ISocketChannel create(Socket socket) throws IOException { >+ return new SocketChannel(socket); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/LocalConnectionImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/LocalConnectionImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/LocalConnectionImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/LocalConnectionImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,204 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: LocalConnectionImpl.java,v 1.9 2006/04/06 15:28:01 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.util.Enumeration; >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.security.AuthenticationListener; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+import org.eclipse.tptp.platform.agentcontroller.internal.DirectConnectionListener; >+import org.eclipse.tptp.platform.agentcontroller.internal.impl.ConnectionFactoryImpl; >+import org.eclipse.tptp.platform.agentcontroller.internal.impl.DirectControlConnectionImpl; >+ >+public class LocalConnectionImpl implements Connection, DirectConnectionListener { >+ private Node _node = null; >+ private ContextMapper _contextMapper; >+ private long _context = 0; >+ private Object _contextLock; >+ private Vector _authenticationlisteners; >+ private Vector _connectionListeners; >+ private DirectControlConnectionImpl _control; >+ private boolean _isActive = false; >+ >+ /** >+ * Please instantiate this through the factory method >+ * >+ */ >+ public LocalConnectionImpl() { >+ _contextMapper = new ContextMapper(); >+ _contextLock = new Object(); >+ _authenticationlisteners = new Vector(); >+ _connectionListeners = new Vector(); >+ } >+ >+ public void addAuthenticationListener(AuthenticationListener listener) { >+ synchronized(_authenticationlisteners) { >+ if(!_authenticationlisteners.contains(listener)) { >+ _authenticationlisteners.add(listener); >+ } >+ } >+ } >+ >+ public void addConnectionListener(ConnectionListener listener) { >+ synchronized(_connectionListeners) { >+ if(!_connectionListeners.contains(listener)) { >+ _connectionListeners.add(listener); >+ } >+ } >+ } >+ >+ public void connect(Node node, int port) throws IOException, SecureConnectionRequiredException, LoginFailedException, UntrustedAgentControllerException { >+ /* >+ * Destroy the direct connection >+ */ >+ _control = ConnectionFactoryImpl.createDirectControlConnection(); >+ _control.setDirectConnectionListener(this); >+ >+ /* >+ * Notify the listeners that the connection is successful >+ */ >+ Enumeration listeners = _authenticationlisteners.elements(); >+ while(listeners.hasMoreElements()) { >+ ((AuthenticationListener)listeners.nextElement()).authenticationSuccessful(this); >+ } >+ >+ _isActive = true; >+ } >+ >+ public void disconnect() { >+ /* >+ * Destroy the direct connection >+ */ >+ _control.removeDirectConnectionListener(); >+ _control = null; >+ >+ /* >+ * Notify the listeners that the connection has been closed >+ */ >+ Enumeration listeners = _connectionListeners.elements(); >+ while(listeners.hasMoreElements()) { >+ ((ConnectionListener)listeners.nextElement()).connectionClosed(this); >+ } >+ >+ _isActive = false; >+ } >+ >+ public Node getNode() { >+ return _node; >+ } >+ >+ public int getPort() { >+ return -1; // No port is being used for local AC >+ } >+ >+ private void incommingCommand(Node node, CommandElement command) { >+ long context = command.getContext(); >+ >+ >+ /* Intercept authentication requests */ >+ switch((int)command.getTag()) { >+ case (int)Constants.RA_SERVER_SECURITY_REQUIREMENTS: >+ break; >+ case (int)Constants.RA_AUTHENTICATION_FAILED: >+ break; >+ case (int)Constants.RA_AUTHENTICATION_SUCCESSFUL: >+ synchronized(_authenticationlisteners) { >+ Enumeration listeners = _authenticationlisteners.elements(); >+ while(listeners.hasMoreElements()) { >+ ((AuthenticationListener)listeners.nextElement()).authenticationSuccessful(this); >+ } >+ } >+ break; >+ default: >+ /* Find the command handler associated with this contextId and >+ forward the message appropriately. >+ */ >+ CommandHandler ch = _contextMapper.getHandler(context); >+ if(ch != null) { >+ ch.incommingCommand(node, command); >+// _contextMapper.removeContext(context); // Prevent memory leak? >+ } >+ else { >+ //TODO: Handle the case where command cannot be sent >+ } >+ } >+ } >+ >+ public boolean isActive() { >+ return _isActive; >+ } >+ >+ public void objectReceived(Object obj) { >+ if(obj instanceof ControlMessage) { >+ ControlMessage cmsg = (ControlMessage)obj; >+ int count = cmsg.getCommandCount(); >+ for(int i = 0; i < count; i++) { >+ incommingCommand(_node, cmsg.getCommand(i)); >+ } >+ } >+ } >+ >+ public void peerClosed() { >+ _isActive = false; >+ } >+ >+ public void removeAuthenticationListener(AuthenticationListener listener) { >+ synchronized(_authenticationlisteners) { >+ if(_authenticationlisteners.contains(listener)) { >+ _authenticationlisteners.remove(listener); >+ } >+ } >+ } >+ >+ public void removeConnectionListener(ConnectionListener listener) { >+ synchronized(_connectionListeners) { >+ if(_connectionListeners.contains(listener)) { >+ _connectionListeners.remove(listener); >+ } >+ } >+ } >+ >+ /** >+ * Send the message to the Agent Controller, not agents >+ */ >+ public void sendMessage(ControlMessage msg, CommandHandler handler) throws IOException { >+ if(handler != null) { >+ synchronized(_contextLock) { >+ int numCommands = msg.getCommandCount(); >+ >+ for(int i = 0; i < numCommands; i++) { >+ msg.getCommand(i).setContext(_context); >+ _contextMapper.addContext(_context, handler); >+ _context++; >+ } >+ } >+ } else { >+ //No need to register a callback context since null is passed to us >+ } >+ _control.sendToQueue(msg); >+ } >+ >+ public void setNode(Node node) { >+ _node = node; >+ _contextMapper.addContext(0, _node); >+ _context++; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ProcessImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ProcessImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ProcessImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ProcessImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,807 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessImpl.java,v 1.15 2006/12/14 23:11:18 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.util.Enumeration; >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Console; >+import org.eclipse.hyades.execution.local.common.ConsoleInfoCommand; >+import org.eclipse.hyades.execution.local.common.ConsoleNotStartedException; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.local.common.DetailedAgentInfoCommand; >+import org.eclipse.hyades.execution.local.common.ErrorCommand; >+import org.eclipse.hyades.execution.local.common.LaunchProcessCommand; >+import org.eclipse.hyades.execution.local.common.LocalConsole; >+import org.eclipse.hyades.execution.local.common.MonitorPeerRequestCommand; >+import org.eclipse.hyades.execution.local.common.MultiplexedDataServer; >+import org.eclipse.hyades.execution.local.common.ProcessExitedCommand; >+import org.eclipse.hyades.execution.local.common.ProcessLaunchedCommand; >+import org.eclipse.hyades.execution.local.common.SimpleAgentInfoCommand; >+ >+public class ProcessImpl implements Process, AgentListener, ConnectionListener { >+ protected String _name = null; >+ >+ protected String _exe = null; >+ >+ protected String _params = null; >+ >+ protected String _location = null; >+ >+ protected String _processId = null; >+ >+ protected String _UUID = null; >+ >+ protected Node _node = null; >+ >+ protected Console _console = null; >+ >+ protected boolean _isActive = false; >+ >+ protected boolean _isComplete = false; >+ >+ protected Vector _agents = new Vector(10); >+ >+ protected Vector _variables = new Vector(20); >+ >+ protected Vector _listeners = new Vector(10); >+ >+ /* This is a lock for launching the process as this is synchronous */ >+ private Object _launcherLock = new Object(); >+ >+ /* >+ * In eclipse, the model changes need to be done on the UI thread, this requires a bit of additional locking that, by rights, shouldn't be required >+ */ >+ private static Object _eclipseLock = new Object(); >+ >+ /* >+ * Lock used for waitForAgent(...) method and agentActive(...) method notification >+ */ >+ private Object _waitForAgentLock = new Object(); >+ >+ private boolean _noSuchAliasExceptionThrown = false; >+ >+ public ProcessImpl(Node node) { >+ this(node, 0); >+ } >+ >+ public ProcessImpl(Node node, long pid) { >+ this(node, null, pid); >+ } >+ >+ public ProcessImpl(Node node, String executable) { >+ this(node, executable, null); >+ } >+ >+ public ProcessImpl(Node node, String executable, String parameters) { >+ _node = node; >+ _exe = executable; >+ _params = parameters; >+ _console = getConsole(); >+ } >+ >+ public ProcessImpl(Node node, String executable, long pid) { >+ _node = node; >+ _exe = executable; >+ _processId = new Long(pid).toString(); >+ } >+ >+ /** >+ * @see Process#launch() >+ */ >+ public void launch() throws ProcessActiveException, NotConnectedException, NoSuchApplicationException { >+ /* >+ * Bug 112677 Here we use a static object lock to make sure each ProcessImpl will not cross each other when launching a process. Even though the ProcessImpl objects are isolated from each other, they are sharing the same Connection object which is used to send messages to the Agent Controller >+ */ >+ synchronized (_eclipseLock) { // Bug 112677 Multiple launches in quick >+ // succession hangs >+ >+ /* Determine if the process is already launched or if it has exited */ >+ if (isActive() || _isComplete) { >+ throw new ProcessActiveException(); >+ } >+ >+ /* Launch the process */ >+ ControlMessage message = new ControlMessage(); >+ LaunchProcessCommand command = new LaunchProcessCommand(); >+ command.setExe(_exe); >+ command.setArgs(_params); >+ command.setLocation(_location); >+ >+ /* Setup the console */ >+ _console = getConsole(); >+ _console.start(); >+ try { >+ command.setConsole(_console); >+ } catch (ConsoleNotStartedException e) { >+ /* We just started the console so this isn't going to happen */ >+ } >+ >+ Enumeration e1 = _variables.elements(); >+ while (e1.hasMoreElements()) { >+ Variable var = (Variable) e1.nextElement(); >+ command.addEnvironmentVariable(var.getName(), var.getValue()); >+ } >+ >+ /* >+ * Enumerate all the agents and add the interest only if autoAttach is true >+ */ >+ Enumeration e2 = _agents.elements(); >+ while (e2.hasMoreElements()) { >+ Agent agent = (Agent) e2.nextElement(); >+ command.addAgent(agent.getName()); >+ } >+ >+ message.appendCommand(command); >+ Connection connection = _node.getConnection(); >+ try { >+ /* >+ * We need to listen in case this connection gets dropped while waiting for the launch to happen >+ */ >+ connection.addConnectionListener(this); >+ connection.sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement command) { >+ handleCommand(command); >+ } >+ }); >+ } catch (IOException e) { >+ throw new NotConnectedException(); >+ } >+ >+ synchronized (_launcherLock) { >+ try { >+ /* >+ * Never wait more than 10 seconds in case something goes wrong >+ */ >+ _launcherLock.wait(10000); >+ } catch (InterruptedException e) { >+ /* We may need to handle this exception */ >+ } >+ } >+ >+ /* If we have a pending NoSuchApplication error we need to throw it. */ >+ if (_noSuchAliasExceptionThrown) { >+ _noSuchAliasExceptionThrown = false; >+ throw new NoSuchApplicationException(); >+ } >+ >+ } // _eclipseLock >+ } >+ >+ /** >+ * @see Process#kill(long) >+ */ >+ public void kill(long delay) throws InactiveProcessException, NotConnectedException { >+ if (_node == null) { >+ throw new InactiveProcessException(); >+ } >+ _node.killProcess(this); >+ } >+ >+ /** >+ * @see Process#addAgent() >+ */ >+ public void addAgent(Agent agent) { >+ if (!_agents.contains(agent)) { >+ _agents.addElement(agent); >+ } >+ >+ } >+ >+ public void removeAgent(Agent agent) { >+ if (_agents.contains(agent)) { >+ _agents.remove(agent); >+ } >+ } >+ >+ /** >+ * @see Process#listAgents() >+ */ >+ public Enumeration listAgents() { >+ return ((Vector) _agents.clone()).elements(); >+ } >+ >+ /** >+ * Remove agents from the process if their name do not exist in the list provided >+ * >+ * @param newList >+ * List of agents that should not be removed >+ */ >+ // Bug 71586 begins >+ public void removeInactiveAgents(String[] newList) { >+ Enumeration agents = listAgents(); >+ while (agents.hasMoreElements()) { >+ Agent a = (Agent) agents.nextElement(); >+ >+ boolean active = false; >+ // Check if the agent is still shown in the new list >+ for (int i = 0; i < newList.length; i++) { >+ if (a.getName().equals(newList[i])) { // Compare the agent's >+ // name >+ active = true; >+ } >+ } >+ >+ // If the agent name does not appear in the new list, remove it. >+ if (!active) { >+ _agents.remove(a); >+ } >+ } >+ } >+ >+ // Bug 71586 ends >+ >+ /** >+ * @see Process#getAgentsByType() >+ */ >+ public Enumeration getAgentsByType(String type) { >+ Vector results = new Vector(); >+ synchronized (_agents) { >+ Enumeration agents = listAgents(); >+ while (agents.hasMoreElements()) { >+ Agent agent = (Agent) agents.nextElement(); >+ String agentType = agent.getType(); >+ if (agentType != null && agentType.equals(type)) { >+ results.addElement(agent); >+ } >+ } >+ } >+ return results.elements(); >+ } >+ >+ public Agent getAgent(String name) { >+ synchronized (_agents) { >+ Enumeration agents = listAgents(); >+ while (agents.hasMoreElements()) { >+ Agent agent = (Agent) agents.nextElement(); >+ if (agent.getName().equals(name)) { >+ return agent; >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * @see Process#getEnvironment() >+ */ >+ public Enumeration getEnvironment() { >+ return _variables.elements(); >+ } >+ >+ /** >+ * @see Process#addProcessListener(ProcessListener) >+ */ >+ public void addProcessListener(ProcessListener listener) { >+ synchronized (_listeners) { >+ if (!_listeners.contains(listener)) { >+ _listeners.add(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Process#removeProcessListener(ProcessListener) >+ */ >+ public void removeProcessListener(ProcessListener listener) { >+ synchronized (_listeners) { >+ if (_listeners.contains(listener)) { >+ _listeners.remove(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Process#getNode() >+ */ >+ public Node getNode() { >+ return _node; >+ } >+ >+ /** >+ * @see Process#setName() >+ */ >+ public void setName(String name) { >+ _name = name; >+ } >+ >+ /** >+ * @see Process#getName() >+ */ >+ public String getName() { >+ return _name; >+ } >+ >+ /** >+ * @see Process#getUUID() >+ */ >+ public String getUUID() { >+ // Bug 58583 >+ int retryCount = 30; // retry 30 times >+ int delay = 1000; // 1 sec between retry, total 30 sec max >+ int i = 0; >+ >+ while ((_UUID == null) && (i < retryCount)) { >+ try { >+ Thread.sleep(delay); >+ } catch (InterruptedException e) { >+ } >+ i++; >+ } >+ >+ return _UUID; >+ } >+ >+ /** >+ * @see Process#isActive() >+ */ >+ public boolean isActive() { >+ return _isActive; >+ } >+ >+ public void setActive(boolean isActive) { >+ _isActive = isActive; >+ } >+ >+ /** >+ * @see Process#getConsole() >+ */ >+ public Console getConsole() { >+ >+ if (_console == null) { >+ >+ Connection conn = getNode().getConnection(); >+ if (conn instanceof LocalConnectionImpl) { >+ _console = new LocalConsole(); >+ } else { >+ this._console = new Console(this._node); >+ } >+ } >+ return _console; >+ } >+ >+ public Console getLocalConsole() { >+ if (_console == null) { >+ _console = new LocalConsole(); >+ } >+ return _console; >+ } >+ >+ /** >+ * @see Process#addEnvironmentVariable() >+ */ >+ public void addEnvironmentVariable(Variable variable) throws ProcessActiveException { >+ if (_isActive) { >+ throw new ProcessActiveException(); >+ } >+ _variables.add(variable); >+ >+ } >+ >+ /** >+ * @see Process#getEnvironmentVariable >+ */ >+ public Variable getEnvironmentVariable(String name) { >+ Enumeration e = getEnvironment(); >+ while (e.hasMoreElements()) { >+ Variable var = (Variable) e.nextElement(); >+ if (var.getName().equals(name)) { >+ return var; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * @see Process#removeEnvironmentVariable >+ */ >+ public void removeEnvironmentVariable(Variable variable) throws ProcessActiveException { >+ if (_isActive) { >+ throw new ProcessActiveException(); >+ } >+ _variables.remove(variable); >+ >+ } >+ >+ /** >+ * @see Process#setExecutable() >+ */ >+ public void setExecutable(String exe) throws ProcessActiveException { >+ if (_isActive) { >+ throw new ProcessActiveException(); >+ } >+ _exe = exe; >+ } >+ >+ /** >+ * @see Process#getExecutable() >+ */ >+ public String getExecutable() { >+ return _exe; >+ } >+ >+ /** >+ * @see Process#setParameters() >+ */ >+ public void setParameters(String params) throws ProcessActiveException { >+ if (_isActive) { >+ throw new ProcessActiveException(); >+ } >+ _params = params; >+ } >+ >+ /** >+ * @see Process#getParameters() >+ */ >+ public String getParameters() { >+ return _params; >+ } >+ >+ /** >+ * @see Process#setLocation() >+ */ >+ public void setLocation(String location) throws ProcessActiveException { >+ if (_isActive) { >+ throw new ProcessActiveException(); >+ } >+ _location = location; >+ } >+ >+ /** >+ * @see Process#getProcessId() >+ */ >+ public String getProcessId() throws InactiveProcessException { >+ // Bug 58583 >+ int retryCount = 30; // retry 30 times >+ int delay = 1000; // 1 sec between retry, total 30 sec max >+ int i = 0; >+ >+ while ((_processId == null) && (i < retryCount)) { >+ try { >+ Thread.sleep(delay); >+ } catch (InterruptedException e) { >+ } >+ i++; >+ } >+ >+ if (_processId == null) { >+ throw new InactiveProcessException(); >+ } >+ return _processId; >+ } >+ >+ public void setProcessId(String pid) { >+ _processId = pid; >+ } >+ >+ /** >+ * @see AgentListener#agentActive >+ */ >+ public void agentActive(Agent agent) { >+ if (!_agents.contains(agent)) { >+ _agents.add(agent); >+ } >+ /* >+ * Notify any waiting thread in the waitForAgent(...) method to minimize time spent waiting for next poll point. >+ */ >+ synchronized (this._waitForAgentLock) { >+ this._waitForAgentLock.notifyAll(); >+ } >+ } >+ >+ /** >+ * @see AgentListener#agentInactive >+ */ >+ public void agentInactive(Agent agent) { >+ /* Should we remove this from the agent list? */ >+ if (agent instanceof AgentImpl) { >+ AgentImpl _agent = (AgentImpl) agent; >+ if (_agent._listeners != null && _agent._listeners.size() > 0) { >+ for (int i = 0; i < _agent._listeners.size(); i++) { >+ Object listener = _agent._listeners.get(i); >+ if (listener instanceof MultiplexedDataServer) >+ return; >+ } >+ } >+ } >+ >+ if (_agents.contains(agent)) { >+ _agents.remove(agent); >+ } >+ } >+ >+ /** >+ * @see AgentListener#error >+ */ >+ public void error(Agent agent, String errorId, String errorMessage) { >+ /* Ignore */ >+ } >+ >+ /** >+ * @see AgentListener#handleCommand >+ */ >+ public void handleCommand(Agent agent, CommandElement command) { >+ /* Ignore */ >+ } >+ >+ /** >+ * @see ConnectionListener#connectionClosed >+ */ >+ public void connectionClosed(Connection connection) { >+ /* >+ * If there is a pending launch lock we need to release it as our connection has been lost >+ */ >+ synchronized (_launcherLock) { >+ _launcherLock.notify(); >+ } >+ } >+ >+ public String getlocation() { >+ return _location; >+ } >+ >+ /** >+ * @see Process#getUUID() >+ */ >+ public void setUUID(String uuid) { >+ _UUID = uuid; >+ } >+ >+ protected void handleCommand(CommandElement command) { >+ Enumeration agents = null; >+ >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_PROCESS_LAUNCHED: >+ /* Only process a ProcessLaunched command once */ >+ if (_isActive) { >+ break; >+ } >+ >+ /* Extract all the information for this process */ >+ ProcessLaunchedCommand plc = (ProcessLaunchedCommand) command; >+ _processId = new Long(plc.getProcessId()).toString(); >+ _UUID = plc.getProcessUUID(); >+ >+ /* Capture all the environment variables */ >+ _variables.removeAllElements(); >+ String[] vars = plc.getEnvironment(); >+ for (int i = 0; i < vars.length; i++) { >+ int equalsOffset = vars[i].indexOf('='); >+ if (equalsOffset > 0) { >+ String name = vars[i].substring(0, equalsOffset); >+ String value = vars[i].substring(equalsOffset + 1); >+ _variables.addElement(new Variable(name, value)); >+ } >+ } >+ >+ _isActive = true; >+ >+ try { >+ /* Inform the listeners that the process is launched */ >+ synchronized (_listeners) { >+ Enumeration e = _listeners.elements(); >+ while (e.hasMoreElements()) { >+ ((ProcessListener) e.nextElement()).processLaunched(this); >+ } >+ } >+ >+ } finally { >+ /* >+ * Remove our connection listener and if the connection is hosed we need to throw a exception >+ */ >+ Connection connection = _node.getConnection(); >+ connection.removeConnectionListener(this); >+ // if(!connection.isActive()) { >+ // throw new NotConnectedException(); >+ // } >+ >+ /* >+ * If our process failed to launch properly then we need to stop the console thread >+ */ >+ if (!isActive() && _console != null) { >+ _console.close(); >+ } >+ >+ } >+ >+ /* Notify that the process is launched so "launch()" can return */ >+ synchronized (_launcherLock) { >+ _launcherLock.notify(); >+ } >+ break; >+ case (int) Constants.RA_AGENT_ACTIVE: >+ case (int) Constants.RA_AGENT_INACTIVE: >+ /* >+ * When an agent becomes active/inactive we need to ensure it is a member of the agent list for this process. We also need to inform all the listeners for this agent that it is active/inactive. This is accomplished by delegating to the handleCommand() of the AgentImpl >+ */ >+ DetailedAgentInfoCommand aac = (DetailedAgentInfoCommand) command; >+ synchronized (_agents) { >+ Agent agent = null; >+ agents = _agents.elements(); >+ while (agents.hasMoreElements()) { >+ Agent current = (Agent) agents.nextElement(); >+ if (current.getName().equals(aac.getAgentName())) { >+ agent = current; >+ break; >+ } >+ } >+ if (agent == null) { >+ agent = AgentFactory.createAgent(this, aac.getAgentName(), aac.getAgentType()); // TODO: Should we do this >+ // for RA_AGENT_INACTIVE? >+ ((AgentImpl) agent).setUUID(aac.getAgentUUID()); >+ } >+ >+ /* >+ * Forward this command to the agent so it can handle the details >+ */ >+ try { >+ AgentImpl agentImpl = (AgentImpl) agent; >+ if (agent.getUUID() == null) { >+ agentImpl.setUUID(aac.getAgentUUID()); >+ } >+ agentImpl.handleCommand(command); >+ >+ } catch (ClassCastException exc) { >+ /* >+ * This is not an instance of AgentImpl, do not attempt to notify it is active >+ */ >+ } >+ >+ } >+ break; >+ case (int) Constants.RA_ERROR_STRING: >+ /* When we are launching a process there could be an error */ >+ ErrorCommand ec = (ErrorCommand) command; >+ if (ec.getErrorId().equals("RAC002")) { >+ _noSuchAliasExceptionThrown = true; >+ synchronized (_launcherLock) { >+ _launcherLock.notify(); >+ } >+ } >+ >+ agents = _agents.elements(); >+ while (agents.hasMoreElements()) { >+ Agent agent = (Agent) agents.nextElement(); >+ if (agent.getName().equals(ec.getAgentName())) { >+ try { >+ ((AgentImpl) agent).handleCommand(command); >+ } catch (ClassCastException exc) { >+ // TODO: Error casting agent >+ } >+ >+ } >+ } >+ >+ break; >+ case (int) Constants.RA_PROCESS_EXITED: >+ ProcessExitedCommand peCmd = (ProcessExitedCommand) command; >+ if (_console != null) { >+ _console.close(); /* Close the console port when process exits */ >+ } >+ >+ if (!_isComplete) { >+ _isComplete = true; >+ synchronized (_listeners) { >+ Enumeration e = _listeners.elements(); >+ while (e.hasMoreElements()) { >+ ((ProcessListener) e.nextElement()).processExited(this); >+ } >+ } >+ >+ // Clean up process members as the process exits (avoid memory >+ // leaks) >+ this._listeners.clear(); >+ this._variables.clear(); >+ this._agents.clear(); >+ >+ } >+ >+ /* Notify the agents */ >+ agents = _agents.elements(); >+ while (agents.hasMoreElements()) { >+ Agent agent = (Agent) agents.nextElement(); // Notify all agents >+ try { >+ ((AgentImpl) agent).handleCommand(command); >+ } catch (ClassCastException exc) { >+ // TODO: Error casting agent >+ } >+ } >+ >+ ((NodeImpl) _node).removeProcess(peCmd.getProcessId()); >+ >+ break; >+ case (int) Constants.RA_CONSOLE_INFO: >+ ConsoleInfoCommand ciCmd = (ConsoleInfoCommand) command; >+ if (_console instanceof LocalConsole) { >+ ((LocalConsole) _console).setStdOut(ciCmd.getStdOut()); >+ ((LocalConsole) _console).setStdErr(ciCmd.getStdErr()); >+ ((LocalConsole) _console).setStdIn(ciCmd.getStdIn()); >+ } >+ break; >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR: >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR_PORT: { >+ MonitorPeerRequestCommand cmd = (MonitorPeerRequestCommand) command; >+ String agentName = cmd.getAgentName(); >+ >+ agents = _agents.elements(); >+ while (agents.hasMoreElements()) { >+ Agent agent = (Agent) agents.nextElement(); // Notify all agents >+ if (agent.getName().equals(agentName)) { >+ try { >+ ((AgentImpl) agent).handleCommand(command); >+ } catch (ClassCastException exc) { >+ // TODO: Error casting agent >+ } >+ } >+ } >+ >+ break; >+ } >+ default: >+ if (command instanceof SimpleAgentInfoCommand) { >+ /* >+ * Custom commands can be generated by agents running on this process. Find the proper agent and forward the message on to it. This gets invoked only when a launch is done not attach, as these are routed directly to the agent. >+ */ >+ Agent agent = getAgent(((SimpleAgentInfoCommand) command).getAgentName()); >+ try { >+ if (agent != null) { >+ ((AgentImpl) agent).handleCommand(command); >+ } >+ } catch (ClassCastException e) { >+ /* This isn;t our impl so we can ignore the command */ >+ } >+ } >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * Waits for a particular agent to be present or the timeout value to be reached; after the agent list returns (the internal agent list in this process instance is updated) the agent is retrieved via the get agent method. The timeout value is approximate since there is some time needed to execute the various operations within the loop and each wait is done timeout divided by 2000 times. For example, a 60000 (60 second) timeout would cause the loop to execute 30 times and wait for 2 seconds at the end of each process list query. >+ */ >+ public Agent waitForAgent(String agentType, String agentName, int timeout) throws NotConnectedException, InactiveProcessException { >+ >+ synchronized (this._waitForAgentLock) { >+ >+ // Change this from a polling model into a notify model (this is >+ // good enough for now) >+ try { >+ for (int i = 0, j = timeout / 2000; i < j; i++) { >+ this.getNode().fastListProcesses(); // bugzilla_92619 (without >+ // this, agents are never >+ // refreshed) >+ for (Enumeration agents = this.listAgents(); agents.hasMoreElements();) { >+ Agent agent = (Agent) agents.nextElement(); >+ if (agent.getName().indexOf(agentName) != -1) { // checks >+ // for >+ // proper >+ // substring >+ return agent; >+ } >+ } >+ this._waitForAgentLock.wait(2000); >+ } >+ } catch (InterruptedException e) { >+ // Do not need to handle this >+ e.printStackTrace(); >+ } >+ >+ return null; // no agent was found in the allowed time >+ } >+ >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentConfiguration.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentConfiguration.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentConfiguration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentConfiguration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentConfiguration.java,v 1.5 2006/04/06 15:28:01 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.util.Vector; >+ >+public class AgentConfiguration { >+ protected String _agentName = null; >+ protected Vector _entries = new Vector(); >+ >+ /** >+ * AgentConfiguration constructor comment. >+ */ >+ public AgentConfiguration() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:18:32 AM) >+ * >+ * @param param >+ * an agent configuration entry >+ */ >+ public void addEntry(AgentConfigurationEntry entry) { >+ _entries.addElement(entry); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/15/2001 3:47:31 PM) >+ */ >+ public void clear() { >+ _entries.clear(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:20:58 AM) >+ * >+ * @return java.lang.String >+ */ >+ public String getAgentName() { >+ return _agentName; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 12:32:57 PM) >+ * >+ * @return the requested agent configuration entry >+ * @param offset >+ * int >+ */ >+ public AgentConfigurationEntry getEntryAt(int offset) { >+ return (AgentConfigurationEntry) _entries.elementAt(offset); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:20:29 AM) >+ * >+ * @param name >+ * java.lang.String >+ */ >+ public void setAgentName(String name) { >+ _agentName = name; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 12:30:28 PM) >+ * >+ * @return int >+ */ >+ public int size() { >+ return _entries.size(); >+ } >+ >+ /** >+ * Removes an entry from this configuration. >+ */ >+ public boolean removeEntry(AgentConfigurationEntry entry) { >+ return _entries.removeElement(entry); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ExtendedDataServerListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ExtendedDataServerListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ExtendedDataServerListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ExtendedDataServerListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ExtendedDataServerListener.java,v 1.2 2005/09/30 21:45:08 slavescu Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.InputStream; >+ >+public interface ExtendedDataServerListener extends DataServerListener { >+ /** >+ * @param buffer >+ * byte[] >+ * @param length >+ * int >+ * @param peer >+ * java.net.InetAddress >+ */ >+ void incommingData(byte[] buffer, int offset, int length, java.net.InetAddress peer); >+ >+ /** >+ * @param buffer >+ * char[] >+ * @param length >+ * int >+ * @param peer >+ * java.net.InetAddress >+ */ >+ void incommingData(char[] buffer, int offset, int length, java.net.InetAddress peer); >+ >+ /** >+ * @param data >+ * byte[] >+ * @param length >+ * int >+ * @param peer >+ * java.net.InetAddress >+ */ >+ void invalidDataType(byte[] data, int offset, int length, java.net.InetAddress peer); >+ >+ void incommingStream(InputStream inputStream, java.net.InetAddress peer); >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentQueryStateCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentQueryStateCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentQueryStateCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentQueryStateCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentQueryStateCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentQueryStateCommand extends SimpleAgentInfoCommand { >+ >+ /** >+ * Constructor >+ */ >+ public AgentQueryStateCommand() { >+ super(); >+ _tag = RA_AGENT_QUERY_STATE; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/RegisteredProcessListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/RegisteredProcessListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/RegisteredProcessListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/RegisteredProcessListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: RegisteredProcessListCommand.java,v 1.5 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class RegisteredProcessListCommand extends CommandElement implements Constants { >+ private int _processListLength = 0; >+ private long _processList[]; >+ >+ /** >+ * QueryServerCommand constructor comment. >+ */ >+ public RegisteredProcessListCommand() { >+ super(); >+ _tag = RA_PROCESS_LIST; >+ } >+ >+ public RegisteredProcessListCommand(long[] p) { >+ super(); >+ _tag = RA_PROCESS_LIST; >+ _processList = p; >+ _processListLength = p.length; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/12/00 12:14:34 AM) >+ * >+ * @return long[] >+ */ >+ public long[] getProcessList() { >+ return _processList; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // length >+ size += (sizeofLong * _processListLength); >+ >+ return size; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ _processListLength = (int) Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ _processList = new long[_processListLength]; >+ for (int i = 0; i < _processListLength; i++) { >+ _processList[i] = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ } >+ return current; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ >+ current = Message.writeRALongToBuffer(buffer, current, (long) _processListLength); >+ >+ for (int i = 0; i < _processListLength; i++) { >+ current = Message.writeRALongToBuffer(buffer, current, _processList[i]); >+ } >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentAttachedCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentAttachedCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentAttachedCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentAttachedCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentAttachedCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentAttachedCommand extends SimpleAgentInfoCommand { // Bug 54376 >+ >+ /** >+ * Constructor >+ */ >+ public AgentAttachedCommand() { >+ super(); >+ _tag = RA_AGENT_ATTACHED; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/security/UserFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/UserFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/security/UserFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/UserFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: UserFactory.java,v 1.3 2005/09/13 16:46:21 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import java.util.Enumeration; >+import java.util.Hashtable; >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.control.Application; >+ >+public class UserFactory { >+ >+ private static Hashtable _table = new Hashtable(); >+ >+ /** >+ * Create a user for a specific application so that we can have multiple >+ * connections open to a Node. >+ */ >+ public static synchronized User createUser(Application app, String name, String password) throws DuplicateUserException { >+ Vector userList = (Vector) _table.get(app.getName()); >+ >+ if (userList == null) { >+ userList = new Vector(); >+ _table.put(app.getName(), userList); >+ } else { >+ Enumeration e = userList.elements(); >+ while (e.hasMoreElements()) { >+ User user = (User) e.nextElement(); >+ if (user.getName().equals(name)) { >+ throw new DuplicateUserException(); >+ } >+ } >+ >+ } >+ >+ User user = new User(app, name, password); >+ userList.add(user); >+ >+ return user; >+ } >+ >+ public static synchronized void removeAllUsers(Application app) { >+ _table.remove(app.getName()); >+ >+ } >+ >+ public static User removeUser(Application app, String name) { >+ Vector userList = (Vector) _table.get(app.getName()); >+ if (userList != null) { >+ Object[] users = userList.toArray(); >+ for (int i = 0; i < users.length; i++) { >+ User currentUser = (User) users[i]; >+ if (currentUser.getName().equals(name)) { >+ userList.remove(i); >+ return currentUser; >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Retrieve a user for a specific application. >+ */ >+ public static synchronized User getUser(Application app, String name) { >+ User user = null; >+ Vector userList = (Vector) _table.get(app.getName()); >+ if (userList != null) { >+ Enumeration e = userList.elements(); >+ while (e.hasMoreElements()) { >+ user = (User) e.nextElement(); >+ if (user.getName().equals(name)) { >+ return user; >+ } >+ } >+ } >+ return null; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationFailedCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationFailedCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationFailedCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationFailedCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AuthenticationFailedCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AuthenticationFailedCommand extends CommandElement implements Constants { >+ private long _ticket; >+ >+ public AuthenticationFailedCommand() { >+ super(); >+ _tag = RA_AUTHENTICATION_FAILED; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; >+ >+ return size; >+ } >+ >+ public long getTicket() { >+ return _ticket; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.readFromBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.readFromBuffer(buffer, current); >+ _ticket = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.writeToBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _tag); >+ current = Message.writeRALongToBuffer(buffer, current, _ticket); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticateCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticateCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AuthenticateCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AuthenticateCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AuthenticateCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AuthenticateCommand extends CommandElement implements Constants { >+ private RAString _name = new RAString(""); >+ private RAString _password = new RAString("");; >+ >+ public AuthenticateCommand() { >+ super(); >+ _tag = RA_AUTHENTICATE; >+ } >+ >+ public AuthenticateCommand(String name, String password) { >+ this(); >+ _name = new RAString(name); >+ _password = new RAString(password); >+ } >+ >+ public void setName(String name) { >+ _name = new RAString(name); >+ } >+ >+ public void setPassword(String password) { >+ _password = new RAString(password); >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += _name.getSize(); >+ size += _password.getSize(); >+ >+ return size; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.readFromBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.readFromBuffer(buffer, current); >+ current = Message.readRAStringFromBuffer(buffer, current, _name); >+ current = Message.readRAStringFromBuffer(buffer, current, _password); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.writeToBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _tag); >+ current = Message.writeRAStringToBuffer(buffer, current, _name); >+ current = Message.writeRAStringToBuffer(buffer, current, _password); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/MonitorPeerRequestCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,133 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: MonitorPeerRequestCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+import java.net.UnknownHostException; >+ >+public class MonitorPeerRequestCommand extends SimpleAgentInfoCommand { >+ >+ protected RABinaryArray _peerNode = new RABinaryArray(); >+ protected RABinaryArray _targetNode = new RABinaryArray(); >+ protected RAString _peerName = new RAString(""); >+ protected long _peerProcessId; >+ >+ private InetAddress _peerAddress = null; >+ private InetAddress _targetAddress = null; >+ >+ /** >+ * CustomCommand constructor comment. >+ */ >+ public MonitorPeerRequestCommand() { >+ super(); >+ _tag = RA_CONTROLLER_REQUEST_MONITOR; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ return super.getSize() + _peerNode.getSize() + sizeofLong + _peerName.getSize(); >+ >+ } >+ >+ public InetAddress getPeerNode() throws UnknownHostException { >+ /* Check our cache */ >+ if (_peerAddress != null) { >+ return _targetAddress; >+ } >+ if (_peerNode.length() == 0) { >+ return null; >+ } >+ byte[] data = _peerNode.getData(); >+ >+ /* Build a string representing the IP address in decimal form */ >+ String addr = new String(); >+ addr += convertPointAddress(new Byte(data[0]).intValue()); >+ >+ for (int i = 1; i < _peerNode.length(); i++) { >+ addr = addr + "." + convertPointAddress(new Byte(data[i]).intValue()); >+ } >+ >+ /* Lookup the InetAddress objects for this address */ >+ return InetAddress.getByName(addr); >+ } >+ >+ public InetAddress getTargetNode() throws UnknownHostException { >+ /* Check our cache */ >+ if (_targetAddress != null) { >+ return _targetAddress; >+ } >+ if (_targetNode.length() == 0) { >+ return null; >+ } >+ byte[] data = _targetNode.getData(); >+ >+ /* Build a string representing the IP address in decimal form */ >+ String addr = new String(); >+ addr += convertPointAddress(new Byte(data[0]).intValue()); >+ for (int i = 1; i < _targetNode.length(); i++) { >+ addr = addr + "." + convertPointAddress(new Byte(data[i]).intValue()); >+ } >+ >+ /* Lookup the InetAddress objects for this address */ >+ return InetAddress.getByName(addr); >+ >+ } >+ >+ public String getPeerAgentName() { >+ if (_peerName != null) { >+ return _peerName.getData(); >+ } >+ return null; >+ } >+ >+ public long getPeerProcessId() { >+ return _peerProcessId; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRABinaryArrayFromBuffer(buffer, current, _targetNode); >+ _peerProcessId = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ current = Message.readRAStringFromBuffer(buffer, current, _peerName); >+ current = Message.readRABinaryArrayFromBuffer(buffer, current, _peerNode); >+ return current; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRABinaryArrayToBuffer(buffer, current, _targetNode); >+ current = Message.writeRALongToBuffer(buffer, current, _peerProcessId); >+ current = Message.writeRAStringToBuffer(buffer, current, _peerName); >+ current = Message.writeRABinaryArrayToBuffer(buffer, current, _peerNode); >+ return current; >+ } >+ >+ private int convertPointAddress(int pointAddress) { >+ if (pointAddress < 0) { >+ pointAddress = 256 - Math.abs(pointAddress); >+ >+ } >+ return pointAddress; >+ >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentConfigurationEntry.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentConfigurationEntry.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentConfigurationEntry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentConfigurationEntry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,111 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentConfigurationEntry.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class AgentConfigurationEntry { >+ protected String _type = null; >+ protected String _name = null; >+ protected String _value = null; >+ protected boolean _enabled = true; >+ >+ /** >+ * AgentConfigurationEntry constructor comment. >+ */ >+ public AgentConfigurationEntry() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @return java.lang.String >+ */ >+ public java.lang.String getName() { >+ return _name; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @return java.lang.String >+ */ >+ public java.lang.String getType() { >+ return _type; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @return java.lang.String >+ */ >+ public java.lang.String getValue() { >+ return _value; >+ } >+ >+ public boolean isEnabled() { >+ return _enabled; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @param new_name >+ * java.lang.String >+ */ >+ public void setName(java.lang.String new_name) { >+ _name = new_name; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @param new_type >+ * java.lang.String >+ */ >+ public void setType(java.lang.String new_type) { >+ _type = new_type; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/9/00 8:16:49 AM) >+ * >+ * @param new_value >+ * java.lang.String >+ */ >+ public void setValue(java.lang.String new_value) { >+ _value = new_value; >+ } >+ >+ public void setEnabled(boolean enabled) { >+ _enabled = enabled; >+ } >+ >+ public boolean equals(AgentConfigurationEntry rhs) { >+ String rhsType = rhs.getType(); >+ String rhsName = rhs.getName(); >+ String rhsValue = rhs.getValue(); >+ >+ /* Compare each of the strings. If anything is null then they are invalid entries and return not equal */ >+ try { >+ /* Check if all the strings are the same */ >+ if (!(rhsType.equals(_type) && rhsName.equals(_name) && rhsValue.equals(_value))) { >+ return false; >+ } >+ } catch (NullPointerException e) { >+ return false; >+ } >+ >+ return true; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentFactory.java,v 1.3 2005/10/01 14:47:02 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class AgentFactory { >+ >+ /** >+ * Create a new agent instance with the specified name. >+ */ >+ public static Agent createAgent(Process process, String name) { >+ return createAgent(process, name, null); >+ } >+ >+ /** >+ * Create a new agent instance with the specified name and type. >+ */ >+ public static Agent createAgent(Process process, String name, String type) { >+ Agent agent = null; >+ >+ /* >+ * Try to check if there is an agent already registered with the process >+ */ >+ agent = process.getAgent(name); >+ if (agent != null) { // Assumption: Agent names must be unique within a process >+ // Do nothing since the agent already exist >+ } else { >+ agent = new AgentImpl(process, name, type); >+ try { >+ ((ProcessImpl) process).addAgent(agent); >+ agent.addAgentListener((ProcessImpl) process); >+ } catch (ClassCastException e) { >+ /* Cannot set relationship unless process is a ProcessImpl */ >+ } >+ } >+ return agent; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ProcessListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ProcessListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ProcessListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ProcessListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public interface ProcessListener { >+ >+ /** >+ * Invoked when a process is launched. The process parameter contains all the information regarding the process. >+ */ >+ void processLaunched(Process process); >+ >+ /** >+ * Invoked when a process that was previously launched exits.The process parameter contains all the information regarding the process. >+ */ >+ void processExited(Process process); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,796 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentImpl.java,v 1.18 2006/11/06 01:25:26 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.net.InetAddress; >+import java.net.UnknownHostException; >+import java.util.Enumeration; >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.common.AgentQueryStateCommand; >+import org.eclipse.hyades.execution.local.common.AttachToAgentCommand; >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.local.common.CustomCommand; >+import org.eclipse.hyades.execution.local.common.DataProcessor; >+import org.eclipse.hyades.execution.local.common.DetachFromAgentCommand; >+import org.eclipse.hyades.execution.local.common.ErrorCommand; >+import org.eclipse.hyades.execution.local.common.MonitorPeerRequestCommand; >+import org.eclipse.hyades.execution.local.common.MonitorPeerRequestPortCommand; >+import org.eclipse.hyades.execution.local.common.MultiplexedDataServer; >+import org.eclipse.hyades.execution.local.common.RegisterAgentInterestCommand; >+import org.eclipse.hyades.execution.local.common.SetNVPairCommand; >+import org.eclipse.hyades.execution.local.common.StartMonitoringRemoteAgentCommand; >+import org.eclipse.hyades.execution.local.common.StopMonitorCommand; >+import org.eclipse.hyades.execution.local.common.TCPDataServer; >+import org.eclipse.tptp.platform.agentcontroller.internal.DataConnection; >+import org.eclipse.tptp.platform.agentcontroller.internal.impl.ConnectionFactoryImpl; >+ >+public class AgentImpl implements Agent, ProcessListener, ConnectionListener { // Bug 59316 >+ protected String _name = null; >+ protected String _type = null; >+ protected String _uuid = null; >+ protected Process _process = null; >+ protected AgentConfiguration _config; >+ protected boolean _autoAttach = false; >+ protected boolean _isMonitored = false; >+ protected boolean _isActive = false; >+ protected boolean _isAttached = false; >+ protected TCPDataServer _server = null; >+ protected MultiplexedDataServer _server_mux = null; >+ protected String _profileFile = null; >+ protected Vector _listeners = new Vector(10); >+ private Object _lock = new Object(); >+ private boolean _isLocal = false; >+ >+ public static class UncheckedNotConnectedException extends RuntimeException { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 3579779634351360004L; >+ } >+ >+ public AgentImpl(Process process, String name) { >+ this(process, name, null); >+ } >+ >+ public AgentImpl(Process process, String name, String type) { >+ this(process, name, type, false); >+ } >+ >+ public AgentImpl(Process process, String name, String type, boolean active) { >+ _process = process; >+ _name = name; >+ _type = type; >+ _isActive = active; >+ process.addProcessListener(this); >+ try { >+ Connection _connection = process.getNode().getConnection(); >+ if (_connection != null) { >+ _connection.addConnectionListener(this); // Bug 59316 >+ } else { >+ // bugzilla 79348 fix, throw NotConnectedException >+ // if Connection is null for this node >+ // In this case, the Agent was created before the node was >+ // connected >+ throw new UncheckedNotConnectedException(); >+ } >+ >+ // Check if this is running on the same machine as the agent >+ if (_connection instanceof LocalConnectionImpl) { >+ _isLocal = true; >+ _connection.addConnectionListener(this); >+ } >+ } catch (InactiveProcessException e) { >+ } >+ } >+ >+ /** >+ * @see Agent#addAgentListener(AgentListener) >+ */ >+ public void addAgentListener(AgentListener listener) { >+ synchronized (_listeners) { >+ if (!_listeners.contains(listener)) { >+ _listeners.add(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Agent#removeAgentListener(AgentListener) >+ */ >+ public void removeAgentListener(AgentListener listener) { >+ synchronized (_listeners) { >+ if (_listeners.contains(listener)) { >+ _listeners.remove(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Agent#getProcess() >+ */ >+ public Process getProcess() { >+ return _process; >+ } >+ >+ /** >+ * @see Agent#setAutoAttach(boolean) >+ */ >+ public void setAutoAttach(boolean auto) { >+ _autoAttach = auto; >+ Process proc = getProcess(); >+ >+ /* >+ * If the process is active we need to send our registration to the remote server >+ */ >+ if (proc != null) { >+ if (proc.isActive()) { >+ ControlMessage message = new ControlMessage(); >+ RegisterAgentInterestCommand command = new RegisterAgentInterestCommand(); >+ command.setAgentName(_name); >+ try { >+ command.setProcessId(new Long(proc.getProcessId()).longValue()); >+ message.appendCommand(command); >+ proc.getNode().getConnection().sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement element) { >+ handleCommand(element); >+ } >+ }); >+ } catch (InactiveProcessException e) { >+ return; >+ } catch (IOException e) { >+ } >+ } >+ } >+ } >+ >+ /** >+ * @see Agent#isAutoAttach(boolean) >+ */ >+ public boolean isAutoAttach() { >+ return _autoAttach; >+ } >+ >+ /** >+ * @see Agent#attach() >+ */ >+ public void attach() throws InactiveAgentException, InactiveProcessException { >+ /* >+ * We will assume the attach is successful here. This is in fact incorrect but the transport layer must be changed to determine if an attach is in fact successful. >+ */ >+ setAttached(true); >+ >+ ControlMessage message = new ControlMessage(); >+ AttachToAgentCommand command = new AttachToAgentCommand(); >+ command.setAgentName(_name); >+ command.setProcessId(Long.valueOf(getProcess().getProcessId()).longValue()); >+ message.appendCommand(command); >+ try { >+ _process.getNode().getConnection().sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement command) { >+ handleCommand(command); >+ } >+ }); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ } >+ >+ /** >+ * @see Agent#detach() >+ */ >+ public void detach() throws InactiveAgentException, InactiveProcessException { >+ setAttached(false); >+ stopMonitoring(); >+ _server = null; /* 9707 */ >+ _server_mux = null; >+ >+ ControlMessage message = new ControlMessage(); >+ DetachFromAgentCommand command = new DetachFromAgentCommand(); >+ command.setAgentName(_name); >+ command.setProcessId(Long.valueOf(getProcess().getProcessId()).longValue()); >+ message.appendCommand(command); >+ try { >+ _process.getNode().getConnection().sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement command) { >+ handleCommand(command); >+ } >+ >+ }); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ } >+ >+ /** >+ * @see Agent#getType() >+ */ >+ public String getType() { >+ return _type; >+ } >+ >+ /** >+ * @see Agent#getName() >+ */ >+ public String getName() { >+ return _name; >+ } >+ >+ /** >+ * @see Agent#getUUID() >+ */ >+ public String getUUID() { >+ return _uuid; >+ } >+ >+ /** >+ * @see Agent#isActive() >+ */ >+ public boolean isActive() { >+ return _isActive; >+ } >+ >+ /** >+ * @see Agent#isMonitored() >+ */ >+ public boolean isMonitored() { >+ return _isMonitored; >+ } >+ >+ // Bug 54376 begins >+ /** >+ * @see Agent#isAttached() >+ */ >+ public boolean isAttached() { >+ return isAttached(false); >+ } >+ >+ /** >+ * @see Agent#isAttached() >+ */ >+ public boolean isAttached(boolean remote) { >+ if (!remote) { >+ return _isAttached; >+ } >+ >+ ControlMessage message = new ControlMessage(); >+ AgentQueryStateCommand command = new AgentQueryStateCommand(); >+ >+ synchronized (_lock) { >+ try { >+ command.setAgentName(_name); >+ command.setProcessId(Long.valueOf(getProcess().getProcessId()).longValue()); >+ message.appendCommand(command); >+ _process.getNode().getConnection().sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement command) { >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_AGENT_ATTACHED: >+ setAttached(true); >+ synchronized (_lock) { >+ _lock.notify(); >+ } >+ break; >+ case (int) Constants.RA_AGENT_DETACHED: >+ setAttached(false); >+ synchronized (_lock) { >+ _lock.notify(); >+ } >+ break; >+ } >+ } >+ }); >+ _lock.wait(5000); // 5 sec wait max >+ } catch (InactiveProcessException e1) { >+ // this should not occur >+ } catch (IOException e2) { >+ // this should not occur >+ } catch (InterruptedException e3) { >+ // this should not occur >+ } >+ } >+ >+ return _isAttached; >+ } >+ >+ // Bug 54376 ends >+ >+ /** >+ * @see Agent#startMonitoring() >+ */ >+ public void startMonitoring(DataProcessor processor) throws InactiveAgentException { >+ DataConnection dataConnection = null; >+ int port = 0; >+ >+ if (!_isAttached) { >+ return; >+ } >+ >+ // Do not start the server threads if local >+ if (_isLocal) { >+ dataConnection = ConnectionFactoryImpl.createDirectDataConnection(); >+ port = -Integer.parseInt(dataConnection.getConnectionName()); >+ if (_server == null) { >+ _server = new TCPDataServer(dataConnection); >+ try { >+ _server.startServer(processor); >+ } catch (Exception e) { >+ // TODO: >+ } >+ } else { >+ _server.resumeServer(processor); >+ } >+ } else { >+ dataConnection = ConnectionFactoryImpl.createSocketDataConnection(); >+ port = Integer.parseInt(dataConnection.getConnectionName()); >+ >+ if (_server == null) { >+ _server = new TCPDataServer(dataConnection); >+ _server_mux = new MultiplexedDataServer(); >+ addAgentListener(_server_mux); >+ >+ /* 9707 */ >+ try { >+ _server.startServer(processor); >+ _server_mux.startServer(processor); >+ } catch (Exception e) { >+ // TODO: >+ } >+ } else { >+ addAgentListener(_server_mux); /* 157656 */ >+ _server.resumeServer(processor); /* 9707 */ >+ } >+ } // Remote >+ >+ ControlMessage message = new ControlMessage(); >+ StartMonitoringRemoteAgentCommand command = new StartMonitoringRemoteAgentCommand(); >+ command.setAgentName(_name); >+ >+ try { >+ command.setInetAddress(InetAddress.getLocalHost()); >+ } catch (UnknownHostException e1) { >+ } >+ >+ command.setPort((short) port); >+ try { >+ command.setProcessId(Long.parseLong(_process.getProcessId())); >+ message.appendCommand(command); >+ _process.getNode().getConnection().sendMessage(message, null); >+ } catch (InactiveProcessException e) { >+ throw new InactiveAgentException(); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ >+ setMonitored(true); >+ } >+ >+ /** >+ * @see Agent#stopMonitoring() >+ */ >+ public void stopMonitoring() throws InactiveAgentException { >+ if (_server != null) { >+ _server.stopServer(); >+ } >+ >+ if (_server_mux != null) { >+ removeAgentListener(_server_mux); /* 157656 */ >+ } >+ >+ if (!_isMonitored) { >+ return; >+ } >+ >+ ControlMessage message = new ControlMessage(); >+ StopMonitorCommand command = new StopMonitorCommand(); >+ command.setAgentName(_name); >+ try { >+ command.setProcessId(Long.parseLong(_process.getProcessId())); >+ message.appendCommand(command); >+ _process.getNode().getConnection().sendMessage(message, null); >+ } catch (InactiveProcessException e) { >+ throw new InactiveAgentException(); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ setMonitored(false); >+ } >+ >+ /** >+ * @see Agent#setConfiguration() >+ */ >+ public void setConfiguration(AgentConfiguration config) { >+ _config = config; >+ } >+ >+ /** >+ * @see Agent#getConfiguration >+ */ >+ public AgentConfiguration getConfiguration() { >+ if (_config == null) { >+ _config = new AgentConfiguration(); >+ } >+ return _config; >+ } >+ >+ /** >+ * @see Agent#publishConfiguration >+ */ >+ public void publishConfiguration() throws InactiveAgentException { >+ if (!_isActive) { >+ throw new InactiveAgentException(); >+ } >+ if (_config == null) { >+ return; >+ } >+ int entryCount = 0; >+ ControlMessage message = new ControlMessage(); >+ synchronized (_config) { >+ for (int i = 0; i < _config.size(); i++) { >+ AgentConfigurationEntry entry = _config.getEntryAt(i); >+ if (entry != null && entry.isEnabled()) { >+ entryCount++; >+ SetNVPairCommand command = new SetNVPairCommand(); >+ try { >+ command.setProcessId(Long.parseLong(_process.getProcessId())); >+ } catch (InactiveProcessException e) { >+ throw new InactiveAgentException(); >+ } >+ command.setAgentName(_name); >+ command.setType(entry.getType()); >+ command.setName(entry.getName()); >+ command.setValue(entry.getValue()); >+ message.appendCommand(command); >+ } >+ } >+ } >+ if (entryCount > 0) { >+ try { >+ _process.getNode().getConnection().sendMessage(message, null); >+ } catch (InactiveProcessException e) { >+ throw new InactiveAgentException(); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ } >+ } >+ >+ /** >+ * @see Agent#invokeCustomCommand() >+ */ >+ public void invokeCustomCommand(CustomCommand command) throws InactiveAgentException { >+ if (!_isActive) { >+ throw new InactiveAgentException(); >+ } >+ ControlMessage message = new ControlMessage(); >+ message.appendCommand(command); >+ command.setAgentName(_name); >+ try { >+ command.setProcessId(Long.parseLong(_process.getProcessId())); >+ _process.getNode().getConnection().sendMessage(message, new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement element) { >+ handleCommand(element); >+ } >+ }); >+ } catch (InactiveProcessException e) { >+ throw new InactiveAgentException(); >+ } catch (IOException e) { >+ /* We need to handle this */ >+ } >+ } >+ >+ public void setUUID(String uuid) { >+ _uuid = uuid; >+ } >+ >+ /** >+ * This is the local handler for >+ */ >+ public void handleCommand(final CommandElement command) { >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_AGENT_ACTIVE: >+ synchronized (_listeners) { >+ setActive(true); >+ if (_autoAttach) { >+ setAttached(true); >+ } >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).agentActive(this); >+ } >+ } >+ break; >+ case (int) Constants.RA_AGENT_INACTIVE: >+ synchronized (_listeners) { >+ setActive(false); >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).agentInactive(this); >+ } >+ // _listeners.clear(); // clear listeners after agent becomes >+ // inactive >+ } >+ break; >+ case (int) Constants.RA_ERROR_STRING: >+ synchronized (_listeners) { >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).error(this, ((ErrorCommand) command).getErrorId(), ((ErrorCommand) command).getErrorString()); >+ } >+ >+ } >+ break; >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR: >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR_PORT: // Bug >+ // 77768 >+ synchronized (_listeners) { >+ /* >+ * We need to ensure we have the peer node/process/agent in our model >+ */ >+ try { >+ InetAddress address = ((MonitorPeerRequestCommand) command).getPeerNode(); >+ if (address != null) { >+ final Node node = NodeFactory.createNode(address.getHostAddress()); >+ >+ /* >+ * RKD: We shouldn't do the connect here. This should be delegated to the listener so that the proper connection can be opened and the appropriate authenticationListeners can be added to the connection. >+ */ >+ if (!node.isConnected()) { >+ /* Bug 77768 begins */ >+ int port; >+ if (command.getTag() == (int) Constants.RA_CONTROLLER_REQUEST_MONITOR_PORT) { >+ port = (int) ((MonitorPeerRequestPortCommand) command).getTargetPort(); >+ } else { >+ port = (int) Constants.CTL_PORT_NUM_SERVER; >+ } >+ node.connect(port); >+ /* Bug 77768 ends */ >+ } >+ >+ final Agent agent = this; >+ >+ /* >+ * My initial plan was to call list processes here but that blocks the calling thread until the background processing is done. The problem with this is that the background thread is this thread..so we deadlock. So the new plan is to create another thread to do the remainder of the notification. >+ */ >+ >+ Runnable delegate = new Runnable() { >+ public void run() { >+ >+ /* Refresh our process list on the node */ >+ String peerProcessId = Long.toString(((MonitorPeerRequestCommand) command).getProcessId()); >+ Enumeration processes = null; >+ >+ try { >+ processes = node.listProcesses(); >+ } catch (NotConnectedException e) { >+ /* >+ * We are the connnection thread so this cannot happen >+ */ >+ } >+ >+ Process proc = null; >+ while (processes.hasMoreElements()) { >+ proc = (Process) processes.nextElement(); >+ try { >+ if (proc.getProcessId().equals(peerProcessId)) { >+ break; >+ } >+ proc = null; >+ } catch (InactiveProcessException e) { >+ /* Ignore inactive processes */ >+ } >+ >+ } >+ >+ /* >+ * The process may have exited. Onceagainwe should probably inform the requesting Agent Controller >+ */ >+ if (proc == null) { >+ return; >+ } >+ >+ Agent peer = proc.getAgent(((MonitorPeerRequestCommand) command).getAgentName()); >+ >+ if (peer == null) { >+ return; >+ } >+ >+ /* Inform the listeners */ >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ AgentListener listener = ((AgentListener) elements.nextElement()); >+ if (listener instanceof AgentPeerListener) { >+ ((AgentPeerListener) listener).peerWaiting(agent, peer); >+ } >+ } >+ } >+ }; >+ >+ Thread newThread = new Thread(delegate, "PeerDelegate"); >+ newThread.start(); >+ } >+ } catch (UnknownHostException e) { >+ /* >+ * We can't resolve the target host, for now we will break. We may need to send an error message back to the forwarding RAC. >+ */ >+ break; >+ } catch (AgentControllerUnavailableException e) { >+ /* >+ * We cannot reach the RAC on this machine, this hould only occur as a result of bad name resolution as the RAC requested a connect. >+ */ >+ } >+ >+ } >+ break; >+ case (int) Constants.RA_PROCESS_EXITED: >+ /* >+ * Beacuse of context mappings we may directly hear that this process has exited rather then the command being routed to the process. This is because context on the server side is held in the agent. >+ */ >+ try { >+ ProcessImpl process = (ProcessImpl) this.getProcess(); >+ if (process != null) { // Bug 110941 >+ processExited(process); // Do this first before cleaning up the Process instance >+ process.handleCommand(command); >+ } >+ } catch (ClassCastException e) { >+ /* We can ignore this */ >+ } >+ break; >+ default: >+ synchronized (_listeners) { >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).handleCommand(this, command); >+ } >+ >+ } >+ } >+ } >+ >+ private void cleanup() { >+ >+ // Remove process listener and clean-up (leaks memory without this >+ // clean-up) >+ if (this._process != null) { >+ try { >+ _process.getNode().getConnection().removeConnectionListener(this); // Bug >+ // 59316 >+ } catch (InactiveProcessException e) { >+ } >+ _process = null; >+ } >+ if (this._listeners != null) { >+ this._listeners.clear(); >+ } >+ >+ // Null out the server instance variables >+ _server = null; >+ _server_mux = null; >+ >+ } >+ >+ /** >+ * @see ProcessListener#processLaunched >+ */ >+ public void processLaunched(Process process) { >+ } >+ >+ /** >+ * @see ProcessListener#processExited >+ */ >+ public void processExited(Process process) { >+ /* >+ * It may be that the process dies unexpectantly and the agent believes it is still active. >+ */ >+ >+ if (_server != null) { >+ _server.shutdownServer(); >+ } >+ if (_server_mux != null) { >+ _server_mux.shutdownServer(); >+ } >+ _server = null; >+ _server_mux = null; >+ >+ // Bug 59316 begins >+ /* >+ * This has to be done no matter _server exists or not since the client might just attach to the agent but doesn't start monitoring (so that _server is not created. >+ */ >+ if (process == _process && _isActive) { >+ synchronized (_listeners) { >+ setActive(false); >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).agentInactive(this); >+ } >+ } >+ } >+ // Bug 59316 ends >+ this.cleanup(); >+ } >+ >+ /** >+ * Determine if this agent is sending data to a profiling file >+ */ >+ public boolean isToProfileFile() { >+ return (_profileFile != null && _profileFile.trim().length() != 0); >+ } >+ >+ /** >+ * Get the fully quality path of profiling file >+ * >+ * @return String >+ */ >+ public String getProfileFile() { >+ return _profileFile; >+ } >+ >+ /** >+ * Set the fully quality path of profiling file >+ * >+ * @param _profileFile >+ * The _profileFile to set >+ */ >+ public void setProfileFile(String _profileFile) { >+ this._profileFile = _profileFile; >+ } >+ >+ // Bug 59316 begins >+ public void connectionClosed(Connection connection) { >+ synchronized (_listeners) { >+ setActive(false); >+ Enumeration elements = _listeners.elements(); >+ while (elements.hasMoreElements()) { >+ ((AgentListener) elements.nextElement()).agentInactive(this); >+ } >+ } >+ } >+ >+ // Bug 59316 ends >+ >+ /** >+ * Additional setters and getters >+ */ >+ public void setProcess(Process p) { >+ _process = p; >+ } >+ >+ public void setType(String type) { >+ _type = type; >+ } >+ >+ public void setName(String name) { >+ _name = name; >+ } >+ >+ public void setActive(boolean isActive) { >+ _isActive = isActive; >+ >+ if (!isActive) { >+ setMonitored(false); >+ setAttached(false); >+ } >+ } >+ >+ public void setMonitored(boolean isMonitored) { >+ _isMonitored = isMonitored; >+ } >+ >+ public void setAttached(boolean isAttached) { >+ _isAttached = isAttached; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/LaunchProcessCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/LaunchProcessCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/LaunchProcessCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/LaunchProcessCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,187 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: LaunchProcessCommand.java,v 1.5 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.util.Vector; >+ >+public class LaunchProcessCommand extends CommandElement implements Constants { >+ private long _consoleIP = 0; // Note: for local direct connetion, this is set to 0 >+ private long _consolePort = 0; // Note: for local direct connetion, this is set to the instance number >+ private RAString _exe = new RAString(""); >+ private RAString _args = new RAString(""); >+ private RAString _location = new RAString(""); >+ private Vector _environment = new Vector(); >+ private Vector _agents = new Vector(); >+ >+ public LaunchProcessCommand() { >+ super(); >+ _tag = RA_LAUNCH_PROCESS; >+ } >+ >+ public void addAgent(String name) { >+ _agents.addElement(new RAString(name)); >+ } >+ >+ public void addEnvironmentVariable(String name, String value) { >+ _environment.addElement(new RAString(name + "=" + value)); >+ } >+ >+ public String getArgs() { >+ if (_args != null) { >+ return _args.getData(); >+ } else { >+ return null; >+ } >+ } >+ >+ public long getConsoleIP() { >+ return _consoleIP; >+ } >+ >+ public long getConsolePort() { >+ return _consolePort; >+ } >+ >+ public String getExe() { >+ if (_exe != null) { >+ return _exe.getData(); >+ } else { >+ return null; >+ } >+ } >+ >+ public String getLocation() { >+ if (_location != null) { >+ return _location.getData(); >+ } else { >+ return null; >+ } >+ } >+ >+ public Vector getEnvironment() { >+ if (_environment != null) { >+ return _environment; >+ } else { >+ return null; >+ } >+ } >+ >+ public Vector getAgents() { >+ if (_agents != null) { >+ return _agents; >+ } else { >+ return null; >+ } >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // consoleIP >+ size += sizeofLong; // consolePort >+ size += +_exe.getSize(); >+ size += _args.getSize(); >+ size += _location.getSize(); >+ >+ size += sizeofLong; // list size >+ for (int i = 0; i < _environment.size(); i++) { >+ size += ((RAString) _environment.elementAt(i)).getSize(); >+ } >+ >+ size += sizeofLong; // list size >+ for (int i = 0; i < _agents.size(); i++) { >+ size += ((RAString) _agents.elementAt(i)).getSize(); >+ } >+ >+ return size; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ _consoleIP = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ _consolePort = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ current = Message.readRAStringFromBuffer(buffer, current, _exe); >+ current = Message.readRAStringFromBuffer(buffer, current, _args); >+ current = Message.readRAStringFromBuffer(buffer, current, _location); >+ >+ long listLength = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ for (int i = 0; i < listLength; i++) { >+ RAString envVar = new RAString(); >+ current = Message.readRAStringFromBuffer(buffer, current, envVar); >+ _environment.addElement(envVar); >+ } >+ >+ listLength = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ for (int i = 0; i < listLength; i++) { >+ RAString envVar = new RAString(); >+ current = Message.readRAStringFromBuffer(buffer, current, envVar); >+ _agents.addElement(envVar); >+ } >+ >+ return current; >+ >+ } >+ >+ public void setArgs(String args) { >+ _args = new RAString(args); >+ } >+ >+ public void setConsole(Console console) throws ConsoleNotStartedException { >+ _consoleIP = console.getIP(); >+ _consolePort = console.getPort(); >+ } >+ >+ public void setConsole(long id) { >+ _consoleIP = 0; >+ _consolePort = id; >+ } >+ >+ public void setExe(String exe) { >+ _exe = new RAString(exe); >+ } >+ >+ public void setLocation(String location) { >+ _location = new RAString(location); >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _consoleIP); >+ current = Message.writeRALongToBuffer(buffer, current, _consolePort); >+ current = Message.writeRAStringToBuffer(buffer, current, _exe); >+ current = Message.writeRAStringToBuffer(buffer, current, _args); >+ current = Message.writeRAStringToBuffer(buffer, current, _location); >+ >+ current = Message.writeRALongToBuffer(buffer, current, (long) _environment.size()); >+ for (int i = 0; i < _environment.size(); i++) { >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) _environment.elementAt(i))); >+ } >+ current = Message.writeRALongToBuffer(buffer, current, (long) _agents.size()); >+ for (int i = 0; i < _agents.size(); i++) { >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) _agents.elementAt(i))); >+ } >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/StopMonitorCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/StopMonitorCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/StopMonitorCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/StopMonitorCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: StopMonitorCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+/** >+ * Insert the type's description here. Creation date: (7/21/00 2:02:57 PM) >+ * >+ * @author: Richard K. Duggan >+ */ >+public class StopMonitorCommand extends SimpleAgentInfoCommand { >+ >+ /** >+ * StopMonitorCommand constructor comment. >+ */ >+ public StopMonitorCommand() { >+ super(); >+ _tag = RA_STOP_MONITORING_AGENT; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ConnectionListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ConnectionListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ConnectionListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public interface ConnectionListener { >+ >+ /** >+ * Invoked when a connection is lost. A connection could be lost due to any number of errors. >+ */ >+ void connectionClosed(Connection connection); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/InactiveAgentException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/InactiveAgentException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/InactiveAgentException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/InactiveAgentException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: InactiveAgentException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class InactiveAgentException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 3237062246917142810L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentActiveCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentActiveCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentActiveCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentActiveCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentActiveCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentActiveCommand extends DetailedAgentInfoCommand { >+ >+ /** >+ * ReadyVMCommand constructor comment. >+ */ >+ public AgentActiveCommand() { >+ super(); >+ _tag = RA_AGENT_ACTIVE; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannel.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannel.java >diff -N src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ISocketChannel.java,v 1.1 2005/09/21 20:51:31 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.hyades.execution.core.file.socket; >+ >+import java.net.Socket; >+import java.nio.channels.Channel; >+import java.nio.channels.ReadableByteChannel; >+import java.nio.channels.WritableByteChannel; >+ >+/** >+ * An abstraction above the socket channel to allow a socket channel to be >+ * emulated by taking a readable byte channel and a writeable byte channel and >+ * combining them into a new interface. Socket channel is a class and not an >+ * interface in Java, so this interface is introduced to satisfy our purposes. >+ * >+ * The file transfer service will work with this socket channel interface >+ * instead of directing using Java's standard socket channel class. >+ * >+ * @author Scott E. Schneider >+ */ >+public interface ISocketChannel extends Channel, ReadableByteChannel, WritableByteChannel { >+ /** >+ * Returns the underlying socket associated with this channel >+ * >+ * @return the socket associated with this channel >+ */ >+ public Socket getSocket(); >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import org.eclipse.hyades.execution.local.common.CommandElement; >+ >+public interface AgentListener { >+ >+ /** >+ * Invoked when an agent first becomes active >+ */ >+ void agentActive(Agent agent); >+ >+ /** >+ * Invoked when an agent becomes inactive. >+ */ >+ void agentInactive(Agent agent); >+ >+ /** >+ * Invoked when an error is recieved from the agent. >+ */ >+ void error(Agent agent, String errorId, String errorMessage); >+ >+ /** >+ * Invoked when there is no established handler for the context of a message. >+ */ >+ void handleCommand(Agent agent, CommandElement command); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/SetNVPairCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/SetNVPairCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/SetNVPairCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/SetNVPairCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SetNVPairCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class SetNVPairCommand extends SimpleAgentInfoCommand { >+ >+ protected RAString _type = new RAString(""); >+ protected RAString _name = new RAString(""); >+ protected RAString _value = new RAString(""); >+ >+ /** >+ * SetNVPairCommand constructor comment. >+ */ >+ public SetNVPairCommand() { >+ super(); >+ _tag = RA_SET_NAME_VALUE_PAIR; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:52:45 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getName() { >+ return _name.getData(); >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ size += _type.getSize(); >+ size += _name.getSize(); >+ size += _value.getSize(); >+ return size; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:53:15 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getType() { >+ return _type.getData(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:53:42 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getValue() { >+ return _value.getData(); >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _type); >+ current = Message.readRAStringFromBuffer(buffer, current, _name); >+ current = Message.readRAStringFromBuffer(buffer, current, _value); >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:55:20 PM) >+ * >+ * @param name >+ * java.lang.String >+ */ >+ public void setName(String name) { >+ _name.setData(name); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:54:59 PM) >+ * >+ * @param type >+ * java.lang.String >+ */ >+ public void setType(String type) { >+ _type.setData(type); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 7:55:53 PM) >+ * >+ * @param value >+ * java.lang.String >+ */ >+ public void setValue(String value) { >+ _value.setData(value); >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _type); >+ current = Message.writeRAStringToBuffer(buffer, current, _name); >+ current = Message.writeRAStringToBuffer(buffer, current, _value); >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentControllerUnavailableException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentControllerUnavailableException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentControllerUnavailableException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentControllerUnavailableException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentControllerUnavailableException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import org.eclipse.hyades.execution.core.DaemonConnectException; >+ >+public class AgentControllerUnavailableException extends DaemonConnectException { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = -4914319348525595629L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/CustomCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/CustomCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/CustomCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/CustomCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: CustomCommand.java,v 1.4 2005/06/09 19:43:05 bjiang Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class CustomCommand extends SimpleAgentInfoCommand { >+ >+ public static final String ENCODING = "UTF-8"; >+ protected RAString _data = null; >+ protected RABinaryArray _binaryData = null; >+ >+ /** >+ * CustomCommand constructor comment. >+ */ >+ public CustomCommand() { >+ super(); >+ _tag = RA_CUSTOM_COMMAND; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (2/20/01 11:23:17 >+ * PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getData() { >+ if (_data != null) { >+ return _data.getData(); >+ } else if (_binaryData != null) { >+ /* >+ * bugzilla 70251 - string data is send over the wire in UTF-8 so >+ * read bytes as UTF-8 >+ */ >+ try { >+ return new String(_binaryData.getData(), ENCODING); >+ } catch (Exception e) { >+ return new String(_binaryData.getData()); >+ } >+ } >+ return null; >+ } >+ >+ public byte[] getDataBinary() { >+ if (_binaryData != null) { >+ return _binaryData.getData(); >+ } else if (_data != null) { >+ try { >+ return _data.getData().getBytes(ENCODING); >+ } catch (Exception e) { >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ if (_data != null) { >+ return super.getSize() + _data.getSize(); >+ } else if (_binaryData != null) { >+ return super.getSize() + _binaryData.getSize(); >+ } >+ /* If neither of these are set, the minimum size is sizeofLong */ >+ return super.getSize() + sizeofLong; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ _binaryData = new RABinaryArray(); >+ current = Message.readRABinaryArrayFromBuffer(buffer, current, _binaryData); >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 8:20:52 PM) >+ * >+ * @param data >+ * java.lang.String >+ */ >+ public void setData(String data) { >+ if (_data == null) { >+ _data = new RAString(data); >+ } else { >+ _data.setData(data); >+ } >+ _binaryData = null; >+ >+ } >+ >+ public void setData(byte[] data) { >+ if (_binaryData == null) { >+ _binaryData = new RABinaryArray(data); >+ } else { >+ _binaryData.setData(data); >+ } >+ _data = null; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current; >+ if (_data != null) { >+ current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _data); >+ } else if (_binaryData != null) { >+ // By eliminating the change to the tag, the command type will >+ // remain unchanged, causing encoding problems >+ // on platforms such as the 390 if custom commands are used >+ // inproperly as binary custom commands. >+ // _tag=RA_BINARY_CUSTOM_COMMAND; >+ current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRABinaryArrayToBuffer(buffer, current, _binaryData); >+ } else { >+ current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, new RAString("")); >+ } >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ServerSecurityInfoCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ServerSecurityInfoCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ServerSecurityInfoCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ServerSecurityInfoCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ServerSecurityInfoCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ServerSecurityInfoCommand extends CommandElement implements Constants { >+ private long _flag; >+ private long _port; >+ >+ public ServerSecurityInfoCommand() { >+ super(); >+ _tag = RA_SERVER_SECURITY_REQUIREMENTS; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // flag >+ size += sizeofLong; // port >+ >+ return size; >+ } >+ >+ public long getSecurePort() { >+ return _port; >+ } >+ >+ public boolean isPasswordProtected() { >+ return _flag < 3; >+ } >+ >+ public boolean isClientAuthenticationRequired() { >+ return _flag > 1; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.readFromBuffer() since this command does not have a context >+ */ >+ // current = super.readFromBuffer(buffer, current); >+ _flag = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ _port = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.writeToBuffer() since this command does not have a context >+ */ >+ // current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _tag); >+ current = Message.writeRALongToBuffer(buffer, current, _flag); >+ current = Message.writeRALongToBuffer(buffer, current, _port); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentConfigurationCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentConfigurationCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentConfigurationCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentConfigurationCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,187 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentConfigurationCommand.java,v 1.3 2006/03/06 19:49:40 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.control.AgentConfigurationEntry; >+ >+public class AgentConfigurationCommand extends CommandElement implements Constants { >+ private long processId = 0; >+ private RAString processUUID = new RAString(); >+ private RAString agentName = new RAString(); >+ private RAString agentUUID = new RAString(); >+ private RAString agentType = new RAString(); >+ private RAString nodeUUID = new RAString(); >+ private Vector entries = new Vector(); >+ >+ public AgentConfigurationCommand() { >+ _tag = Constants.RA_AGENT_CONFIGURATION; >+ } >+ >+ public int getSize() { >+ int size = 0; >+ >+ size += super.getSize(); >+ >+ size += sizeofLong; // processId >+ >+ size += processUUID.getSize(); >+ size += agentName.getSize(); >+ size += agentUUID.getSize(); >+ size += agentType.getSize(); >+ size += nodeUUID.getSize(); >+ >+ size += sizeofLong; // num of entries >+ for (int i = 0; i < entries.size(); i++) { >+ RAString name = new RAString(((AgentConfigurationEntry) entries.elementAt(i)).getName()); >+ RAString type = new RAString(((AgentConfigurationEntry) entries.elementAt(i)).getType()); >+ RAString value = new RAString(((AgentConfigurationEntry) entries.elementAt(i)).getValue()); >+ >+ size += name.getSize(); >+ size += type.getSize(); >+ size += value.getSize(); >+ } >+ >+ return size; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ long numConfig; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ processId = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ current = Message.readRAStringFromBuffer(buffer, current, processUUID); >+ current = Message.readRAStringFromBuffer(buffer, current, agentName); >+ current = Message.readRAStringFromBuffer(buffer, current, agentUUID); >+ current = Message.readRAStringFromBuffer(buffer, current, agentType); >+ current = Message.readRAStringFromBuffer(buffer, current, nodeUUID); >+ >+ numConfig = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ for (int i = 0; i < numConfig; i++) { >+ RAString type = new RAString(); >+ RAString name = new RAString(); >+ RAString value = new RAString(); >+ >+ current = Message.readRAStringFromBuffer(buffer, current, type); >+ current = Message.readRAStringFromBuffer(buffer, current, name); >+ current = Message.readRAStringFromBuffer(buffer, current, value); >+ >+ AgentConfigurationEntry entry = new AgentConfigurationEntry(); >+ entry.setType(type.getData()); >+ entry.setName(name.getData()); >+ entry.setValue(value.getData()); >+ >+ addEntry(entry); >+ } >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, processId); >+ current = Message.writeRAStringToBuffer(buffer, current, processUUID); >+ current = Message.writeRAStringToBuffer(buffer, current, agentName); >+ current = Message.writeRAStringToBuffer(buffer, current, agentUUID); >+ current = Message.writeRAStringToBuffer(buffer, current, agentType); >+ current = Message.writeRAStringToBuffer(buffer, current, nodeUUID); >+ current = Message.writeRALongToBuffer(buffer, current, entries.size()); >+ for (int i = 0; i < entries.size(); i++) { >+ AgentConfigurationEntry entry = (AgentConfigurationEntry) entries.elementAt(i); >+ current = Message.writeRAStringToBuffer(buffer, current, new RAString(entry.getType())); >+ current = Message.writeRAStringToBuffer(buffer, current, new RAString(entry.getName())); >+ current = Message.writeRAStringToBuffer(buffer, current, new RAString(entry.getValue())); >+ } >+ >+ return current; >+ } >+ >+ public void clear() { >+ entries.clear(); >+ } >+ >+ public AgentConfigurationEntry[] getConfigurations() { >+ return (AgentConfigurationEntry[]) entries.toArray(); >+ } >+ >+ public void addEntry(AgentConfigurationEntry entry) { >+ this.entries.add(entry); >+ } >+ >+ public boolean removeEntry(AgentConfigurationEntry entry) { >+ if (entries.contains(entry)) { >+ entries.remove(entry); >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ public RAString getAgentName() { >+ return agentName; >+ } >+ >+ public void setAgentName(RAString agentName) { >+ this.agentName = agentName; >+ } >+ >+ public RAString getAgentType() { >+ return agentType; >+ } >+ >+ public void setAgentType(RAString agentType) { >+ this.agentType = agentType; >+ } >+ >+ public RAString getAgentUUID() { >+ return agentUUID; >+ } >+ >+ public void setAgentUUID(RAString agentUUID) { >+ this.agentUUID = agentUUID; >+ } >+ >+ public RAString getNodeUUID() { >+ return nodeUUID; >+ } >+ >+ public void setNodeUUID(RAString nodeUUID) { >+ this.nodeUUID = nodeUUID; >+ } >+ >+ public long getProcessId() { >+ return processId; >+ } >+ >+ public void setProcessId(long processId) { >+ this.processId = processId; >+ } >+ >+ public RAString getProcessUUID() { >+ return processUUID; >+ } >+ >+ public void setProcessUUID(RAString processUUID) { >+ this.processUUID = processUUID; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ActiveAgentListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ActiveAgentListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ActiveAgentListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ActiveAgentListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ActiveAgentListCommand.java,v 1.3 2005/09/27 20:31:56 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.util.Vector; >+ >+public class ActiveAgentListCommand extends SimpleProcessCommand { >+ >+ protected Vector _agents = new Vector(); >+ protected RAString _processName = new RAString(""); >+ >+ /** >+ * ActiveAgentListCommand constructor comment. >+ */ >+ public ActiveAgentListCommand() { >+ super(); >+ _tag = RA_AGENT_LIST; >+ } >+ >+ public ActiveAgentListCommand(String processName, Vector agents) { >+ super(); >+ _tag = RA_AGENT_LIST; >+ >+ _processName = new RAString(processName); >+ _agents = agents; >+ } >+ >+ public String[] getAgents() { >+ int length = _agents.size(); >+ String[] results = new String[length]; >+ for (int i = 0; i < length; i++) { >+ results[i] = ((RAString) _agents.elementAt(i)).getData(); >+ } >+ return results; >+ } >+ >+ public String getProcessName() { >+ return _processName.getData(); >+ >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ size += _processName.getSize(); >+ size += sizeofLong; >+ for (int i = 0; i < _agents.size(); i++) { >+ size += ((RAString) _agents.elementAt(i)).getSize(); >+ } >+ return size; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _processName); >+ long listLength = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ for (int i = 0; i < listLength; i++) { >+ RAString agent = new RAString(""); >+ current = Message.readRAStringFromBuffer(buffer, current, agent); >+ _agents.addElement(agent); >+ } >+ return current; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _processName); >+ current = Message.writeRALongToBuffer(buffer, current, _agents.size()); >+ for (int i = 0; i < _agents.size(); i++) { >+ current = Message.writeRAStringToBuffer(buffer, current, ((RAString) _agents.elementAt(i))); >+ } >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementHandler.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementHandler.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AcknowledgementHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AcknowledgementHandler.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+ >+public interface AcknowledgementHandler { >+ >+ void incommingAcknowledgement(InetAddress server, long ticket); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentDetachedCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentDetachedCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentDetachedCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentDetachedCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentDetachedCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentDetachedCommand extends SimpleAgentInfoCommand { // Bug 54376 >+ >+ /** >+ * Constructor >+ */ >+ public AgentDetachedCommand() { >+ super(); >+ _tag = RA_AGENT_DETACHED; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ControlServerDaemon.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ControlServerDaemon.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ControlServerDaemon.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ControlServerDaemon.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,143 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ControlServerDaemon.java,v 1.4 2005/09/13 16:46:20 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.IOException; >+import java.net.DatagramPacket; >+import java.net.DatagramSocket; >+import java.net.InetAddress; >+import java.net.SocketException; >+ >+public class ControlServerDaemon implements Constants { >+ >+ private DatagramServer _server = null; >+ private DatagramSocket _sock = null; >+ private AcknowledgementHandler _ackHandler = null; >+ private CommandHandler _cmdHandler = null; >+ >+ class DatagramServer extends Thread implements Constants { >+ DatagramSocket _socket = null; >+ >+ public void setSocket(DatagramSocket sock) { >+ _socket = sock; >+ } >+ >+ public void run() { >+ >+ /* Run forever */ >+ while (true) { >+ byte[] buffer = new byte[MAX_MESSAGE_LENGTH]; >+ DatagramPacket data = new DatagramPacket(buffer, MAX_MESSAGE_LENGTH); >+ try { >+ _socket.receive(data); >+ >+ /* Is this a valid message type */ >+ Message incommingMessage = new Message(); >+ incommingMessage.readFromBuffer(data.getData(), data.getLength()); >+ >+ /* Send an acknowledgement to the message originator */ >+ if (incommingMessage.getType() != RA_ACKNOWLEDGEMENT_MESSAGE) { >+ byte[] responseBuffer = new byte[16]; >+ AcknowledgementMessage ack = new AcknowledgementMessage(); >+ ack.setTicket(incommingMessage.getTicket()); >+ ack.writeToBuffer(responseBuffer, 0); >+ DatagramPacket response = new DatagramPacket(responseBuffer, 12, data.getAddress(), data.getPort()); >+ _socket.send(response); >+ } >+ processMessage(data.getData(), data.getLength(), data.getAddress()); >+ } catch (IOException e) { >+ /* TO_DO: Must provide proper handler */ >+ } >+ } >+ } >+ >+ protected void processMessage(byte[] buffer, int bufferSize, InetAddress server) { >+ long type = Message.readRALongFromBuffer(buffer, 8); >+ switch ((int) type) { >+ case RA_ACKNOWLEDGEMENT_MESSAGE: >+ processAcknowledgementMessage(buffer, bufferSize, server); >+ break; >+ case RA_CONTROL_MESSAGE: >+ processControlMessage(buffer, bufferSize, server); >+ break; >+ default: >+ break; >+ } >+ } >+ >+ protected void processAcknowledgementMessage(byte[] buffer, int bufferSize, InetAddress server) { >+ if (_ackHandler != null) { >+ AcknowledgementMessage msg = new AcknowledgementMessage(); >+ msg.readFromBuffer(buffer, bufferSize); >+ _ackHandler.incommingAcknowledgement(server, msg.getTicket()); >+ } >+ } >+ >+ protected void processControlMessage(byte[] buffer, int bufferSize, InetAddress server) { >+ if (_cmdHandler != null) { >+ ControlMessage msg = new ControlMessage(); >+ msg.readFromBuffer(buffer, bufferSize); >+ >+ /* Valid pass on each command */ >+ int count = msg.getCommandCount(); >+ for (int i = 0; i < count; i++) { >+ _cmdHandler.incommingCommand(server, msg.getCommand(i)); >+ } >+ } >+ } >+ } // end class ControlDatagramServer >+ >+ /** >+ * ControlServer constructor comment. >+ */ >+ public ControlServerDaemon() { >+ super(); >+ } >+ >+ public void sendMessage(byte[] buffer, int length, InetAddress addr) throws IOException { >+ DatagramPacket message = new DatagramPacket(buffer, length, addr, CTL_PORT_NUM_SERVER); >+ _sock.send(message); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 3:16:00 PM) >+ * >+ * @param handler >+ * com.ibm.jvmpi.client.AcknowledgementHandler >+ */ >+ public void setAcknowledgementHandler(AcknowledgementHandler handler) { >+ _ackHandler = handler; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 3:15:10 PM) >+ * >+ * @param handler >+ * com.ibm.jvmpi.client.CommandHandler >+ */ >+ public void setCommandHandler(CommandHandler handler) { >+ _cmdHandler = handler; >+ } >+ >+ public void startServer() throws SocketException { >+ /* Is the server already started? */ >+ if (_server != null) >+ return; >+ _sock = new DatagramSocket(); >+ _server = new DatagramServer(); >+ _server.setSocket(_sock); >+ /* Don't block exit of the VM */ >+ _server.setDaemon(true); >+ _server.start(); >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ConnectionFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ConnectionFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ConnectionFactory.java,v 1.3 2005/10/05 17:33:53 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class ConnectionFactory { >+ >+ public static Connection getLocalConnection(Node node) { >+ LocalConnectionImpl local = new LocalConnectionImpl(); >+ local.setNode(node); >+ >+ return local; >+ } >+ >+ public static Connection getConnection(Node node) { >+ return new ConnectionImpl(); >+ } >+ >+ public static Connection getSecuredConnection(Node node) { >+ return new SecureConnectionImpl(); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/Message.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/Message.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/Message.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/Message.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,268 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Message.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+import java.net.UnknownHostException; >+ >+public class Message implements Constants { >+ >+ /* The protocol version number */ >+ protected long _version = RA_VERSION; >+ >+ /* Length of the message */ >+ protected long _type = 0; >+ >+ /* The ticket number of the message */ >+ protected long _ticket = 0; >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 4:16:27 PM) >+ * >+ * @return int >+ */ >+ public int getSize() { >+ return 4 * sizeofLong; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 1:48:08 PM) >+ * >+ * @return long >+ */ >+ public long getTicket() { >+ return _ticket; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/1/00 3:22:45 PM) >+ * >+ * @return long >+ */ >+ public long getType() { >+ return _type; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 5:58:37 PM) >+ * >+ * @return long >+ */ >+ public long getVersion() { >+ return _version; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 1:50:09 PM) >+ * >+ * @param buffer >+ * byte[] >+ * @param length >+ * int >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ >+ /* magic number */ >+ readRALongFromBuffer(buffer, offset); >+ offset += 4; >+ >+ /* version */ >+ _version = readRALongFromBuffer(buffer, offset); >+ offset += 4; >+ >+ /* type */ >+ _type = readRALongFromBuffer(buffer, offset); >+ offset += 4; >+ >+ /* ticket */ >+ _ticket = readRALongFromBuffer(buffer, offset); >+ offset += 4; >+ >+ return offset; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 6:02:05 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public static long readRALongFromBuffer(byte[] buffer, int offset) { >+ return (long) (buffer[0 + offset] << 24 & 0xff000000) | (long) (buffer[1 + offset] << 16 & 0x00ff0000) | (long) (buffer[2 + offset] << 8 & 0x0000ff00) | (long) (buffer[3 + offset] & 0x000000ff); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 6:03:31 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public static int readRAStringFromBuffer(byte[] buffer, int offset, RAString rastring) { >+ long length = Message.readRALongFromBuffer(buffer, offset); >+ String data; >+ try { >+ data = new String(buffer, offset + 4, (int) length, "UTF-8"); >+ } catch (Throwable e) { >+ data = new String(buffer, 0, offset + 4, (int) length); >+ } >+ rastring.setData(data); >+ >+ return offset + rastring.getSize(); >+ } >+ >+ public static int readRABinaryArrayFromBuffer(byte[] buffer, int offset, RABinaryArray raarray) { >+ long length = Message.readRALongFromBuffer(buffer, offset); >+ raarray.setData(buffer, offset + 4, (int) length); >+ return offset + raarray.getSize(); >+ } >+ >+ public static int readRAInetAddressFromBuffer(byte[] buffer, int offset, RAInetAddress ipaddr) { >+ byte length = buffer[0 + offset]; >+ byte[] address = new byte[length]; >+ for (int i = 0; i < length; i++) { >+ address[i] = buffer[1 + i]; >+ } >+ >+ ipaddr.setLength((int) length); >+ ipaddr.setData(address); >+ >+ return offset + sizeofByte + length; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 1:48:28 PM) >+ * >+ * @param ticket >+ * java.lang.Long >+ */ >+ public void setTicket(long ticket) { >+ _ticket = ticket; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 5:59:43 PM) >+ * >+ * @param version >+ * long >+ */ >+ public void setVersion(long version) { >+ _version = version; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 6:02:05 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public static int writeRALongToBuffer(byte[] buffer, int offset, long ralong) { >+ buffer[0 + offset] = (byte) (ralong >> 24 & 0x000000ff); >+ buffer[1 + offset] = (byte) (ralong >> 16 & 0x000000ff); >+ buffer[2 + offset] = (byte) (ralong >> 8 & 0x000000ff); >+ buffer[3 + offset] = (byte) ralong; >+ return offset + 4; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 6:03:31 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public static int writeRAStringToBuffer(byte[] buffer, int offset, RAString rastring) { >+ byte[] strData; >+ try { >+ strData = rastring.getData().getBytes("UTF-8"); >+ } catch (Throwable e) { >+ strData = rastring.getData().getBytes(); >+ } >+ writeRALongToBuffer(buffer, offset, strData.length); >+ System.arraycopy((Object) strData, 0, (Object) buffer, offset + 4, strData.length); >+ >+ return offset + rastring.getSize(); >+ } >+ >+ public static int writeRABinaryArrayToBuffer(byte[] buffer, int offset, RABinaryArray raarray) { >+ if (raarray == null) { >+ writeRALongToBuffer(buffer, offset, 0); >+ return offset + sizeofLong; >+ } >+ byte[] data = raarray.getData(); >+ writeRALongToBuffer(buffer, offset, data.length); >+ System.arraycopy(data, 0, buffer, offset + 4, data.length); >+ >+ return offset + raarray.getSize(); >+ } >+ >+ public static int writeRAInetAddressToBuffer(byte[] buffer, int offset, RAInetAddress addr) { >+ if (addr == null) { >+ buffer[offset] = 0; >+ return offset + sizeofByte; >+ } >+ try { >+ InetAddress address = addr.getAddress(); >+ if (address == null) { >+ buffer[offset] = 0; >+ return offset + sizeofByte; >+ } >+ byte[] bytes = address.getAddress(); >+ buffer[offset + 0] = (byte) bytes.length; >+ for (int i = 0; i < bytes.length; i++) { >+ buffer[offset + i + sizeofByte] = bytes[i]; >+ } >+ return offset + sizeofByte + bytes.length; >+ >+ } catch (UnknownHostException e) { >+ buffer[offset] = 0; >+ return offset + sizeofByte; >+ >+ } >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/2/00 1:49:08 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* Insert magic header */ >+ current = writeRALongToBuffer(buffer, current, RA_MAGIC); >+ >+ /* Insert the major and minor */ >+ current = writeRALongToBuffer(buffer, current, RA_VERSION); >+ >+ /* Insert the type */ >+ current = writeRALongToBuffer(buffer, current, _type); >+ >+ /* Insert the ticket */ >+ current = writeRALongToBuffer(buffer, current, _ticket); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorPortCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorPortCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorPortCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentRequestMonitorPortCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentRequestMonitorPortCommand.java,v 1.1 2006/03/06 19:49:40 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentRequestMonitorPortCommand extends MonitorPeerRequestPortCommand { >+ >+ public AgentRequestMonitorPortCommand() { >+ super(); >+ _tag = RA_AGENT_REQUEST_MONITOR_PORT; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/SecureConnectionImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/SecureConnectionImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/SecureConnectionImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/SecureConnectionImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,251 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SecureConnectionImpl.java,v 1.9 2006/11/07 00:30:59 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.net.InetAddress; >+import java.net.InetSocketAddress; >+import java.net.Socket; >+import java.net.SocketException; >+import java.nio.channels.SocketChannel; >+import java.security.KeyManagementException; >+import java.security.NoSuchAlgorithmException; >+ >+import javax.net.ssl.KeyManager; >+import javax.net.ssl.SSLContext; >+import javax.net.ssl.SSLSession; >+import javax.net.ssl.SSLSocket; >+import javax.net.ssl.SSLSocketFactory; >+import javax.net.ssl.TrustManager; >+ >+import junit.framework.Assert; >+ >+import org.eclipse.hyades.execution.security.ISecureClientParameters; >+import org.eclipse.hyades.execution.core.file.socket.ISocketChannel; >+import org.eclipse.hyades.execution.core.file.socket.ISocketChannelFactory; >+import org.eclipse.hyades.execution.core.file.socket.SocketChannelFactory; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+ >+public class SecureConnectionImpl extends ConnectionImpl implements ISocketChannelFactory { >+ >+ public SecureConnectionImpl() { >+ super(); >+ } >+ >+ public void connect(Node node, int port) throws IOException, LoginFailedException, SecureConnectionRequiredException, UntrustedAgentControllerException { >+ int protocolOffset = 0; >+ >+ /* Set the node */ >+ _node = node; >+ >+ /* Determine our acceptable protocols */ >+ String[] sslProtocols = getSSLProtocols(); >+ SSLContext sslContext = null; >+ >+ /* Connect to the remote machine */ >+ boolean done = false; >+ >+ /* Get the SSL context */ >+ do { >+ try { >+ sslContext = getSSLContext(sslProtocols[protocolOffset]); >+ done = true; >+ } catch (NoSuchAlgorithmException e) { >+ protocolOffset++; >+ } >+ } while (!done && (protocolOffset < sslProtocols.length)); >+ >+ if (sslContext == null) { >+ throw new IOException("Could not get SSL context. Protocols not supported."); >+ } >+ >+ _socket = getSSLSocket(sslContext, port); >+ _port = port; >+ >+ /* Set the cipher suites */ >+ String[] cipherSuites = getCipherSuites(); >+ ((SSLSocket) _socket).setEnabledCipherSuites(cipherSuites); >+ ((SSLSocket) _socket).setUseClientMode(true); >+ >+ /* >+ * The underlying JSSE code returns the SSL socket before all the SSL handshakes, including client authentication, are completed. The handshake carries on, asynchronously, in the background. If the handshake fails then the socket is not usable. We synchronize things by calling getSession() on the SSL socket. The thread calling getSession() is forced to wait until the underlying SSL handshake is completed, and if the handshake fails then getSession() returns a null. >+ */ >+ SSLSession session = ((SSLSocket) _socket).getSession(); >+ >+ /* >+ * If we could not establish a session we should throw an exception >+ */ >+ if (session == null) { >+ throw new UntrustedAgentControllerException(); >+ } >+ if (session.getCipherSuite().equals("SSL_NULL_WITH_NULL_NULL")) { >+ throw new UntrustedAgentControllerException(); >+ } >+ >+ _node = node; >+ this.init(); >+ } >+ >+ /** >+ * Creates a socket channel using the current _socket state as the abstracted element >+ * >+ * @return >+ * @throws IOException >+ */ >+ private ISocketChannel create() throws IOException { >+ Assert.assertNotNull(this._socket); >+ return this.create(this._socket); >+ } >+ >+ public ISocketChannel create(InetSocketAddress address) throws IOException { >+ >+ Assert.assertNotNull(address); >+ Assert.assertNotNull(this._node); >+ >+ /* >+ * Creates a new socket channel to the given address/port combination, this new socket channel is a new connection and does not affect this secure connection implementation's connection status. It does attempt to use this secure connection implementation's credentials if possible to ease connection, as well as any of state that helps establish a new socket channel from this connection class. >+ * >+ * The node must point to the same host, although the connection port can be different, The address host specified is ignored and only the port information is used in this case. >+ */ >+ SecureConnectionImpl connection = new SecureConnectionImpl() { >+ >+ public void init() { >+ >+ // Override to avoid base class socket reader thread >+ try { >+ this._socket.setSoTimeout(60000); >+ this._socket.setTcpNoDelay(true); >+ this._socket.setReuseAddress(true); >+ } catch (SocketException e) { >+ // >+ } >+ >+ } >+ >+ }; >+ >+ /* >+ * Create a new connection on a different port -- it is expected that no exceptions will occur due to already being validated on the same node as spawning secure connection impl >+ */ >+ try { >+ connection.connect(this._node, address.getPort()); >+ return connection.create(); >+ } catch (SecureConnectionRequiredException e) { >+ // >+ } catch (UntrustedAgentControllerException e) { >+ // >+ } catch (IOException e) { >+ // >+ } catch (LoginFailedException e) { >+ // >+ } >+ return null; >+ >+ } >+ >+ public ISocketChannel create(Socket socket) throws IOException { >+ return SocketChannelFactory.getInstance().create(socket); >+ } >+ >+ public ISocketChannel create(SocketChannel realChannel) { >+ return SocketChannelFactory.getInstance().create(realChannel); >+ } >+ >+ public ISocketChannel create(InetSocketAddress address, int timeout) throws IOException { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ private String[] getCipherSuites() { >+ Node node = getNode(); >+ String[] cipherSuites = null; >+ >+ ISecureClientParameters params = node.getSecurityParameters(); >+ if (params != null) { >+ cipherSuites = params.getEnabledCipherSuites(); >+ } >+ if (cipherSuites == null) { >+ cipherSuites = ((SSLSocket) _socket).getSupportedCipherSuites(); >+ } >+ >+ return cipherSuites; >+ } >+ >+ private SSLContext getSSLContext(String protocol) throws NoSuchAlgorithmException { >+ Node node = getNode(); >+ >+ KeyManager[] kms; >+ TrustManager[] tms; >+ >+ /* Attach using SSL and initiate a handshake */ >+ SSLContext sslContext; >+ sslContext = SSLContext.getInstance(protocol); >+ >+ kms = node.getSecurityParameters().getKeystoreManager().getKeyManagers(); >+ tms = node.getSecurityParameters().getKeystoreManager().getTrustManagers(); >+ >+ try { >+ sslContext.init(kms, tms, null); >+ } catch (KeyManagementException e) { >+ e.printStackTrace(); >+ return null; >+ } >+ >+ return sslContext; >+ } >+ >+ private String[] getSSLProtocols() { >+ Node node = getNode(); >+ >+ /* Determine our acceptable protocols */ >+ String[] sslProtocols; >+ ISecureClientParameters param = node.getSecurityParameters(); >+ if (param != null) { >+ sslProtocols = param.getEnabledProtocols(); >+ if (sslProtocols == null) { >+ sslProtocols = new String[] { "SSL" }; >+ } >+ } else { >+ sslProtocols = new String[] { "SSL" }; >+ } >+ >+ return sslProtocols; >+ } >+ >+ private SSLSocket getSSLSocket(SSLContext sslContext, int port) { >+ int offset = 0; >+ Node node = getNode(); >+ InetAddress[] addrs = node.getAllInetAddresses(); >+ SSLSocket sslSocket = null; >+ boolean done = false; >+ >+ do { >+ try { >+ if (sslContext == null) { >+ sslSocket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(addrs[offset], port); >+ sslSocket.startHandshake(); >+ done = true; >+ } else { >+ sslSocket = (SSLSocket) sslContext.getSocketFactory().createSocket(addrs[offset], port); >+ done = true; >+ } >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } while (!done && (offset < addrs.length)); >+ >+ return sslSocket; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/Constants.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/Constants.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/Constants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/Constants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Constants.java,v 1.9 2006/05/03 19:36:54 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public interface Constants { >+ public static int DEFAULT_TIMEOUT = 10000; >+ >+ public static final String RA_MASTER_ADDRESS = "ramaster"; >+ public static final String RA_PIPE_NAMESPACE = "IBMRAC"; >+ public static final String RA_PIPE_NAMESPACE_WIN32 = "IBMAC"; >+ >+ /* Various Message types currently available */ >+ public static final byte RA_ACKNOWLEDGEMENT_MESSAGE = 0x00000000; >+ public static final byte RA_CONTROL_MESSAGE = 0x00000001; >+ >+ public final static long RA_MAGIC = 0x82656780; >+ public final static byte RA_MAGIC_0 = (byte) (RA_MAGIC >> 24 & 0xff); >+ public final static byte RA_MAGIC_1 = (byte) (RA_MAGIC >> 16 & 0xff); >+ public final static byte RA_MAGIC_2 = (byte) (RA_MAGIC >> 8 & 0xff); >+ public final static byte RA_MAGIC_3 = (byte) (RA_MAGIC & 0xff); >+ >+ public final static long RA_VERSION = 0x00000100; >+ >+ public final static long RA_AUTHENTICATE = 0x00000001; >+ public final static long RA_AUTHENTICATION_FAILED = 0x00000002; >+ public final static long RA_AUTHENTICATION_SUCCESSFUL = 0x00000003; >+ public final static long RA_SERVER_SECURITY_REQUIREMENTS = 0x00000004; >+ public final static long RA_LAUNCH_PROCESS = 0x00000010; >+ public final static long RA_QUERY_PROCESS_LIST = 0x00000011; >+ public final static long RA_QUERY_AGENT_LIST = 0x00000012; >+ public final static long RA_REGISTER_AGENT_NOTIFICATION = 0x00000013; >+ public final static long RA_ATTACH_TO_AGENT = 0x00000014; >+ public final static long RA_DETACH_FROM_AGENT = 0x00000015; >+ public final static long RA_START_MONITORING_AGENT_REMOTE = 0x00000016; >+ public final static long RA_START_MONITORING_AGENT_LOCAL = 0x00000017; >+ public final static long RA_STOP_MONITORING_AGENT = 0x00000018; >+ public final static long RA_SET_NAME_VALUE_PAIR = 0x00000019; >+ public final static long RA_CUSTOM_COMMAND = 0x0000001A; >+ public final static long RA_KILL_PROCESS = 0x0000001B; >+ public final static long RA_QUERY_AGENT_DETAILS = 0x0000001C; >+ public final static long RA_BINARY_CUSTOM_COMMAND = 0x0000001D; >+ public final static long RA_GET_PROPERTY_LIST = 0x0000001E; >+ public final static long RA_MANAGE_FILE = 0x0000001F; >+ public final static long RA_PROCESS_LAUNCHED = 0x00000020; >+ public final static long RA_PROCESS_LIST = 0x00000021; >+ public final static long RA_AGENT_LIST = 0x00000022; >+ public final static long RA_AGENT_ACTIVE = 0x00000023; >+ public final static long RA_AGENT_INACTIVE = 0x00000024; >+ public final static long RA_ERROR_STRING = 0x00000025; >+ public final static long RA_ATTACH_SUCCESSFUL = 0x00000026; // Not used >+ public final static long RA_ATTACH_FAILED = 0x00000027; // Not used >+ public final static long RA_AGENT_DETAILS = 0x00000028; >+ public final static long RA_PROCESS_EXITED = 0x00000029; >+ public final static long RA_PROPERTY_LIST = 0x0000002A; >+ public final static long RA_AGENT_QUERY_STATE = 0x0000002B; >+ public final static long RA_AGENT_ATTACHED = 0x0000002C; >+ public final static long RA_AGENT_DETACHED = 0x0000002D; >+ public final static long RA_LOCAL_AGENT_ACTIVE = 0x00000030; // Not used >+ public final static long RA_AGENT_SCOPING_INFORMATION = 0x00000031; >+ public final static long RA_AGENT_CONFIGURATION = 0x00000032; >+ public final static long RA_AGENT_CONTROLLER_AVAILABLE = 0x00000050; // Not >+ // used >+ public final static long RA_AGENT_CONTROLLER_UNAVAILABLE = 0x00000051; // Not >+ // used >+ public final static long RA_AGENT_REQUEST_MONITOR = 0x00000061; >+ public final static long RA_CONTROLLER_REQUEST_MONITOR = 0x00000062; >+ public final static long RA_PEER_UNREACHABLE = 0x00000063; >+ public final static long RA_CONTROLLER_MONITOR_PEER = 0x00000064; // Not >+ // used >+ public final static long RA_AGENT_REQUEST_MONITOR_PORT = 0x00000065; >+ public final static long RA_CONTROLLER_REQUEST_MONITOR_PORT = 0x00000066; >+ public final static long RA_RESOURCE_LOCATION = 0x00000070; >+ public final static long RA_CONSOLE_INFO = 0x00000080; >+ public final static long RA_SHUTDOWN = 0x000000FF; >+ >+ public final static long RA_GET_FILE = 0x00000001; >+ public final static long RA_PUT_FILE = 0x00000002; >+ public final static long RA_DELETE_FILE = 0x00000003; >+ >+ /** >+ * Various constants that both the client and server must adhere to. >+ */ >+ public final static int CTL_PORT_NUM_SERVER = 10002; /* >+ * hardcoded to >+ * start with >+ */ >+ public final static int CTL_PORT_NUM_CLIENT = 10003; /* >+ * hardcoded to >+ * start with >+ */ >+ public final static int MESSAGE_HEADER_LENGTH = 10; /* >+ * 10 byte header to >+ * start with >+ */ >+ public final static int MAX_MESSAGE_LENGTH = 8096; /* >+ * The maximum size of a >+ * message >+ */ >+ public final static int MAX_COMMAND_LINE_LENGTH = 512; /* >+ * Maximum length of >+ * a command line >+ * string >+ */ >+ public final static int DATA_PORT_NUM_CLIENT = 10004; >+ public final static int MAX_DATA_LENGTH = 4096; /* >+ * The size of the data >+ * buffer for sockets >+ */ >+ >+ /* >+ * This package is ported from C, so to facilitate sizeof code for >+ * primitives the following constants are provided >+ */ >+ >+ public final static int sizeofByte = 1; >+ public static final int sizeofChar = 2; >+ public static final int sizeofShort = 2; >+ public static final int sizeofLong = 4; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/QueryAgentListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: QueryAgentListCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class QueryAgentListCommand extends SimpleProcessCommand { >+ >+ /** >+ * QueryAgentList constructor comment. >+ */ >+ public QueryAgentListCommand() { >+ super(); >+ _tag = RA_QUERY_AGENT_LIST; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ErrorCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ErrorCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ErrorCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ErrorCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ErrorCommand.java,v 1.3 2006/04/24 14:58:32 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ErrorCommand extends SimpleAgentInfoCommand implements Constants { >+ >+ protected long _severity; >+ >+ protected RAString _errorId = new RAString(""); >+ >+ protected RAString _errorString = new RAString(""); >+ >+ /** >+ * ErrorCommand constructor comment. >+ */ >+ public ErrorCommand() { >+ super(); >+ _tag = RA_ERROR_STRING; >+ } >+ >+ public String getErrorId() { >+ return _errorId._data; >+ } >+ >+ public String getErrorString() { >+ return _errorString._data; >+ } >+ >+ public long getSeverity() { >+ return _severity; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ size += sizeofLong; >+ size += _errorId.getSize(); >+ size += _errorString.getSize(); >+ return size; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ _severity = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ current = Message.readRAStringFromBuffer(buffer, current, _errorId); >+ current = Message.readRAStringFromBuffer(buffer, current, _errorString); >+ return current; >+ } >+ >+ public void setErrorId(String id) { >+ _errorId = new RAString(id); >+ } >+ >+ public void setErrorString(String s) { >+ _errorString = new RAString(s); >+ } >+ >+ public void setSeverity(long sev) { >+ _severity = sev; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRALongToBuffer(buffer, current, _severity); >+ current = Message.writeRAStringToBuffer(buffer, current, _errorId); >+ current = Message.writeRAStringToBuffer(buffer, current, _errorString); >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ErrorListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ErrorListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ErrorListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ErrorListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ErrorListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+/** >+ * This is the interface that all errors will notified on. >+ */ >+public interface ErrorListener { >+ >+ void error(String errorId, String error); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/MultiplexedDataServer.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/MultiplexedDataServer.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/MultiplexedDataServer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/MultiplexedDataServer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,173 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: MultiplexedDataServer.java,v 1.10 2006/10/30 18:25:49 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ ***********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+ >+import org.eclipse.hyades.execution.local.control.Agent; >+import org.eclipse.hyades.execution.local.control.AgentListener; >+import org.eclipse.hyades.execution.local.control.InactiveProcessException; >+import org.eclipse.hyades.execution.local.control.ProcessImpl; >+ >+/** >+ * Please see TCPDataServer for implmentation details. >+ */ >+public class MultiplexedDataServer implements AgentListener, Constants { >+ private Agent _agent; >+ private DataProcessor _processor; >+ private long magicNumber = 0xFEEDC0DE; >+ private long terminationCode = 0xDEADC0DE; >+ private InetAddress inetaddr = null; >+ >+ /* Different types of data */ >+ public static final byte BINARY_DATA = 0; >+ public static final byte UTF8_STRING_DATA = 1; >+ public static final byte UNICODE_STRING_DATA = 2; >+ >+ public void startServer(DataProcessor processor) throws Exception { >+ _processor = processor; >+ } >+ >+ public boolean isProcessing() { >+ return true; // always processing >+ } >+ >+ public void stopServer() { >+ } >+ >+ public void resumeServer() { >+ } >+ >+ public void resumeServer(DataProcessor processor) { >+ } >+ >+ public void shutdownServer() { >+ this._processor = null; >+ } >+ >+ public void incommingData(byte[] b, InetAddress peer) { >+ _processor.incommingData(b, b.length, peer); >+ } >+ >+ public void incommingData(char[] c, InetAddress peer) { >+ _processor.incommingData(c, c.length, peer); >+ } >+ >+ public void agentActive(Agent agent) { >+ try { >+ inetaddr = agent.getProcess().getNode().getInetAddress(); >+ } catch (InactiveProcessException e) { >+ } >+ } >+ >+ public void agentInactive(Agent agent) { >+ this._agent = agent; >+ } >+ >+ public void error(Agent agent, String errorId, String errorMessage) { >+ } >+ >+ public void handleCommand(Agent agent, CommandElement command) { >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_BINARY_CUSTOM_COMMAND: >+ BinaryCustomCommand binaryCustomCommand = (BinaryCustomCommand) command; >+ int binaryDataLength; >+ byte[] binaryData; >+ >+ // The byte array data and length >+ binaryData = binaryCustomCommand.getDataBinary(); >+ binaryDataLength = binaryData.length; >+ >+ if (binaryDataLength >= sizeofLong) { >+ // Read the magic number >+ long code = Message.readRALongFromBuffer(binaryData, 0); >+ >+ if (code == magicNumber) { >+ // Read the actual multiplexed data >+ byte b[] = new byte[binaryDataLength - 4]; >+ System.arraycopy(binaryData, 4, b, 0, binaryDataLength - 4); >+ processData(b, inetaddr); >+ } else if (code == terminationCode) { >+ /* Notify that the flusher is exiting */ >+ if (_processor instanceof DataServerListener) { >+ ((DataServerListener) _processor).dataServerExited(); >+ } >+ if (this._agent != null && this._agent.getProcess() != null && this._agent.getProcess() instanceof ProcessImpl) { >+ ((ProcessImpl) this._agent.getProcess()).removeAgent(this._agent); >+ } >+ } >+ } >+ break; >+ } >+ } >+ >+ private void processData(byte[] data, InetAddress addr) { >+ if (data.length > Constants.MESSAGE_HEADER_LENGTH) { >+ if (isValidHeader(data)) { >+ int length = (int) getMessageLength(data); >+ byte type = getMessageType(data); >+ >+ if (length + Constants.MESSAGE_HEADER_LENGTH <= data.length) { >+ if (type == BINARY_DATA || type == UTF8_STRING_DATA) { >+ byte[] forwardBuffer = new byte[length]; >+ System.arraycopy(data, Constants.MESSAGE_HEADER_LENGTH, forwardBuffer, 0, length); >+ _processor.incommingData(forwardBuffer, length, addr); >+ } else if (type == UNICODE_STRING_DATA) { // double-byte >+ int strlen = length / 2; >+ char[] forwardBuffer = new char[strlen]; >+ for (int i = 0; i < strlen; i++) { >+ forwardBuffer[i] = (char) ((char) data[Constants.MESSAGE_HEADER_LENGTH + 2 * i] | (char) (data[Constants.MESSAGE_HEADER_LENGTH + 2 * i + 1] << 8)); >+ } >+ _processor.incommingData(forwardBuffer, strlen, addr); >+ } else { >+ System.err.println("ERROR: Corrupted data in multiplexed data"); >+ } >+ } else { >+ System.err.println("ERROR: multiplexed message does not have enough bytes as specified in the message length attribute"); >+ } >+ } else { >+ System.err.println("ERROR: multiplexed message does not have a valid header"); >+ } >+ } else { >+ System.err.println("ERROR: multiplexed message does not have enough header bytes"); >+ } >+ } >+ >+ /** >+ * Get the length of the current message >+ */ >+ private long getMessageLength(byte[] b) { >+ return Message.readRALongFromBuffer(b, 5); >+ } >+ >+ /** >+ * Get the message type. There are currently three types of messages. BINARY_DATA, UTF8_STRING_DATA, UNICODE_STRING_DATA. >+ */ >+ private byte getMessageType(byte[] b) { >+ return b[9]; >+ >+ } >+ >+ /** >+ * Check the message magic number. If the magic number is incorrect we need to go into recovery mode >+ */ >+ private boolean isValidHeader(byte[] b) { >+ boolean valid = false; >+ >+ if ((b[0] == Constants.RA_MAGIC_0) && (b[1] == Constants.RA_MAGIC_1) && (b[2] == Constants.RA_MAGIC_2) && (b[3] == Constants.RA_MAGIC_3)) { >+ valid = true; >+ } >+ >+ return valid; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/CommandHandler.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/CommandHandler.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/CommandHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/CommandHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: CommandHandler.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import org.eclipse.hyades.execution.local.common.CommandElement; >+ >+public interface CommandHandler { >+ >+ void incommingCommand(Node node, CommandElement command); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/SimpleAgentInfoCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/SimpleAgentInfoCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/SimpleAgentInfoCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/SimpleAgentInfoCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SimpleAgentInfoCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public abstract class SimpleAgentInfoCommand extends SimpleProcessCommand implements Constants { >+ >+ protected RAString _agentName = new RAString(""); >+ >+ /** >+ * ProcessInfoCommandEntry constructor comment. >+ */ >+ public SimpleAgentInfoCommand() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 9:12:04 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getAgentName() { >+ if (_agentName != null) >+ return _agentName.getData(); >+ return null; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 12:54:50 PM) >+ * >+ * @return int >+ */ >+ public int getSize() { >+ return super.getSize() + _agentName.getSize(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 9:25:14 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param length >+ * int[] >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _agentName); >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 9:11:41 PM) >+ * >+ * @param name >+ * java.lang.String >+ */ >+ public void setAgentName(String name) { >+ _agentName = new RAString(name); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (7/21/00 2:35:32 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _agentName); >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentScopingInformationCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentScopingInformationCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentScopingInformationCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentScopingInformationCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,151 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentScopingInformationCommand.java,v 1.3 2006/03/06 19:49:40 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentScopingInformationCommand extends CommandElement implements Constants { >+ private long processId; >+ private long messageProcessId; >+ private RAString processUUID = new RAString(); >+ private RAString agentName = new RAString(); >+ private RAString agentUUID = new RAString(); >+ private RAString agentType = new RAString(); >+ private RAString nodeUUID = new RAString(); >+ >+ public AgentScopingInformationCommand() { >+ _tag = Constants.RA_AGENT_SCOPING_INFORMATION; >+ } >+ >+ public int getSize() { >+ int size = 0; >+ >+ size += super.getSize(); >+ >+ size += sizeofLong; // processId >+ if (System.getProperty("os.name").startsWith("Linux")) { >+ size += sizeofLong; // messageProcessId; >+ } >+ size += processUUID.getSize(); >+ size += agentName.getSize(); >+ size += agentUUID.getSize(); >+ size += agentType.getSize(); >+ size += nodeUUID.getSize(); >+ >+ return size; >+ } >+ >+ /** >+ * Read the buffer to populate the class content. No need to read the tag >+ * since it is already being read by the handler >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ processId = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ if (System.getProperty("os.name").startsWith("Linux")) { >+ messageProcessId = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ } >+ >+ current = Message.readRAStringFromBuffer(buffer, current, processUUID); >+ current = Message.readRAStringFromBuffer(buffer, current, agentName); >+ current = Message.readRAStringFromBuffer(buffer, current, agentUUID); >+ current = Message.readRAStringFromBuffer(buffer, current, agentType); >+ current = Message.readRAStringFromBuffer(buffer, current, nodeUUID); >+ >+ return current; >+ } >+ >+ /** >+ * Need to write the class content to the buffer, that includes the tag as >+ * well >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, processId); >+ >+ if (System.getProperty("os.name").startsWith("Linux")) { >+ current = Message.writeRALongToBuffer(buffer, current, messageProcessId); >+ } >+ >+ current = Message.writeRAStringToBuffer(buffer, current, processUUID); >+ current = Message.writeRAStringToBuffer(buffer, current, agentName); >+ current = Message.writeRAStringToBuffer(buffer, current, agentUUID); >+ current = Message.writeRAStringToBuffer(buffer, current, agentType); >+ current = Message.writeRAStringToBuffer(buffer, current, nodeUUID); >+ >+ return current; >+ } >+ >+ public RAString getAgentName() { >+ return agentName; >+ } >+ >+ public void setAgentName(RAString agentName) { >+ this.agentName = agentName; >+ } >+ >+ public RAString getAgentType() { >+ return agentType; >+ } >+ >+ public void setAgentType(RAString agentType) { >+ this.agentType = agentType; >+ } >+ >+ public RAString getAgentUUID() { >+ return agentUUID; >+ } >+ >+ public void setAgentUUID(RAString agentUUID) { >+ this.agentUUID = agentUUID; >+ } >+ >+ public long getMessageProcessId() { >+ return messageProcessId; >+ } >+ >+ public void setMessageProcessId(long messageProcessId) { >+ this.messageProcessId = messageProcessId; >+ } >+ >+ public RAString getNodeUUID() { >+ return nodeUUID; >+ } >+ >+ public void setNodeUUID(RAString nodeUUID) { >+ this.nodeUUID = nodeUUID; >+ } >+ >+ public long getProcessId() { >+ return processId; >+ } >+ >+ public void setProcessId(long processId) { >+ this.processId = processId; >+ } >+ >+ public RAString getProcessUUID() { >+ return processUUID; >+ } >+ >+ public void setProcessUUID(RAString processUUID) { >+ this.processUUID = processUUID; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/InvalidMessageException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/InvalidMessageException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/InvalidMessageException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/InvalidMessageException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: InvalidMessageException.java,v 1.4 2005/10/08 14:28:53 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class InvalidMessageException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = -4943674624497132355L; >+ >+ /** >+ * InvalidMessageException constructor comment. >+ */ >+ public InvalidMessageException() { >+ super(); >+ } >+ >+ /** >+ * InvalidMessageException constructor comment. >+ * >+ * @param s >+ * java.lang.String >+ */ >+ public InvalidMessageException(String s) { >+ super(s); >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/KillProcessCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/KillProcessCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/KillProcessCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/KillProcessCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: KillProcessCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class KillProcessCommand extends SimpleProcessCommand { >+ >+ /** >+ * KillProcessCommand constructor comment. >+ */ >+ public KillProcessCommand() { >+ super(); >+ _tag = RA_KILL_PROCESS; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/CommandHandler.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/CommandHandler.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/CommandHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/CommandHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: CommandHandler.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+ >+public interface CommandHandler { >+ >+ void incommingCommand(InetAddress server, CommandElement command); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/TCPDataServer.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/TCPDataServer.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/TCPDataServer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/TCPDataServer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1137 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: TCPDataServer.java,v 1.36 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InterruptedIOException; >+import java.net.InetAddress; >+ >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; >+ >+import org.eclipse.hyades.execution.local.CommunicationDebug; >+import org.eclipse.tptp.platform.agentcontroller.internal.DataConnection; >+ >+public class TCPDataServer { >+ private String MESSAGE_VALUE_ID = "messageValue"; >+ >+ private DataConnection _dataConnection = null; >+ >+ private TCPDataProcessor _server = null; >+ >+ private BufferFlusher _flusher = null; >+ >+ private int _port; >+ >+ private boolean _isDataServerRunning = true; // Bug 90153 >+ >+ /* >+ * Buffers for getting incomming data off the socket reader and onto a dispatch thread >+ */ >+ private static final short NUM_BUFFERS = 32; >+ >+ private SingleBuffer[] _bufferArray; >+ >+ private short _currentFullBuffers = 0; >+ >+ /* Different types of data */ >+ public static final byte BINARY_DATA = 0; >+ >+ public static final byte UTF8_STRING_DATA = 1; >+ >+ public static final byte UNICODE_STRING_DATA = 2; >+ >+ private int totalBytes = 0; // Bug 90153 >+ >+ public static final int BUFFER_SIZE = 8 * Constants.MAX_MESSAGE_LENGTH; // 64K >+ >+ public TCPDataServer() { >+ super(); >+ } >+ >+ public TCPDataServer(DataConnection connection) { >+ _dataConnection = connection; >+ } >+ >+ class SingleBuffer implements Constants { >+ public InetAddress addr; >+ >+ public int length = 0; >+ >+ public int size = MAX_MESSAGE_LENGTH; >+ >+ public byte[] data = new byte[MAX_MESSAGE_LENGTH]; >+ >+ } >+ >+ class TCPDataProcessor extends Thread implements Constants { >+ boolean _processing = true; >+ protected boolean _shutdown = false; /* 9707 */ >+ protected short _currentFillerBuffer = 0; >+ >+ public TCPDataProcessor() { >+ } >+ >+ /* 9707 */ >+ public void resumeProcessing() { >+ synchronized (this) { >+ _processing = true; >+ } >+ } >+ >+ /* 9707 */ >+ public void pauseProcessing() { >+ synchronized (this) { >+ _processing = false; >+ } >+ } >+ >+ /* 9707 */ >+ public boolean isProcessing() { >+ synchronized (this) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServer.isProcessing()=" + _processing + " - " + this); >+ } >+ return _processing; >+ } >+ } >+ >+ /* 9707 */ >+ public void shutdown() { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServer.shutdown() - " + this); >+ } >+ _shutdown = true; >+ pauseProcessing(); >+ interrupt(); >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServer.shutdown(): after - " + this); >+ } >+ } >+ >+ public void run() { >+ _isDataServerRunning = true; // Bug 90153 >+ >+ /* Run forever */ >+ outer: while (!_shutdown || (_currentFullBuffers != 0)) { /* 9707 */ >+ if (isProcessing()) { >+ _dataConnection.create(); >+ InputStream is; >+ do { >+ is = _dataConnection.getInputStream(); >+ if (is == null) { >+ try { >+ Thread.sleep(1000); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ } >+ } >+ } while (is == null); >+ >+ while (true) { >+ /* If all the buffers are full wait for the first one to be emptied */ >+ while (_currentFullBuffers == NUM_BUFFERS) { >+ synchronized (_bufferArray[0]) { >+ try { >+ _bufferArray[0].wait(); >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ >+ /* Fill the next buffer */ >+ _bufferArray[_currentFillerBuffer].addr = _dataConnection.getAddress(); >+ try { >+ _bufferArray[_currentFillerBuffer].length = is.read(_bufferArray[_currentFillerBuffer].data); >+ /* System.out.println("---Read "+_bufferArray[_currentFillerBuffer].length+" bytes"); */ >+ int _bytes = _bufferArray[_currentFillerBuffer].length; // Bug 90153 >+ totalBytes += _bytes; >+ // System.out.println("---------------------Read "+_bytes+" into _bufferArray["+_currentFillerBuffer+"]"); >+ // System.out.println("---------------------Read "+totalBytes+" bytes in total"); >+ if (_bytes == -1) { >+ _isDataServerRunning = false; >+ } >+ } catch (InterruptedIOException e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ e.printStackTrace(System.out); >+ } >+ /* Read timeout, don't want to wait too long */ >+ >+ /* This is used to terminate the thread if the process is killed abnormally */ >+ if (_shutdown && (_currentFullBuffers == 0)) { >+ pauseProcessing(); >+ _isDataServerRunning = false; // Bug 90153 >+ _dataConnection.destroyConnection(); /* 9707 */ >+ break outer; >+ } >+ } catch (IOException e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ e.printStackTrace(System.out); >+ } >+ /* Socket is toast, we are done */ >+ pauseProcessing(); >+ _isDataServerRunning = false; // Bug 90153 >+ _dataConnection.destroyConnection(); /* 9707 */ >+ break outer; >+ } >+ >+ /* Is the connection closed? */ >+ if (_bufferArray[_currentFillerBuffer].length < 0) { >+ pauseProcessing(); >+ _isDataServerRunning = false; // Bug 90153 >+ /* Will hit here when detaching agent */ >+ _dataConnection.destroyConnection(); >+ break outer; >+ } >+ synchronized (_bufferArray[0]) { >+ if (_bufferArray[_currentFillerBuffer].length > 0) { >+ /* Move on to the next buffer */ >+ _currentFillerBuffer++; >+ if (_currentFillerBuffer == NUM_BUFFERS) { >+ _currentFillerBuffer = 0; >+ } >+ _currentFullBuffers++; >+ >+ /* Is this the first buffer filled? */ >+ if (_currentFullBuffers == 1) { >+ _bufferArray[0].notifyAll(); >+ } >+ } >+ } >+ } >+ } else { >+ try { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessor.run() - Monitoring is stopped, keep this thread in sleep state !"); >+ } >+ /* Monitoring is stopped, keep this thread in sleep state */ >+ sleep(1000); /* 9707 */ >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ } >+ >+ } /* end class TCPDataProcessor */ >+ >+ class BufferFlusher extends Thread implements Constants { >+ private DataProcessor _processor = null; >+ >+ private byte[] _binaryForwardBuffer = new byte[MAX_MESSAGE_LENGTH]; >+ >+ private char[] _stringForwardBuffer = new char[MAX_MESSAGE_LENGTH]; >+ >+ private byte[] _messageHeader = new byte[MESSAGE_HEADER_LENGTH]; >+ >+ private long _currentBufferSize = MAX_MESSAGE_LENGTH; >+ >+ private short _currentFlusherBuffer = 0; >+ >+ private int _currentHeaderOffset = 0; >+ >+ private int _bytesWritten = 0; >+ >+ public void setProcessor(DataProcessor processor) { >+ _processor = processor; >+ } >+ >+ /** >+ * Load the _messageHeader from a buffer of data >+ * >+ * @param data - >+ * the byte[] holding the raw data. >+ * @param offset - >+ * where the header starts in the raw data buffer. >+ * @param length - >+ * the length of the raw data buffer. >+ * @returns - the new offset in the raw data buffer to continue reading from. >+ */ >+ protected int loadMessageHeader(byte[] data, int offset, int limit) { >+ /* Load all we can into the header */ >+ while (offset < limit && _currentHeaderOffset < MESSAGE_HEADER_LENGTH) { >+ _messageHeader[_currentHeaderOffset++] = data[offset++]; >+ } >+ return offset; >+ } >+ >+ /** >+ * Get the length of the current message >+ */ >+ protected long getMessageLength() { >+ return Message.readRALongFromBuffer(_messageHeader, 5); >+ } >+ >+ /** >+ * Get the message type. There are currently three types of messages. BINARY_DATA, UTF8_STRING_DATA, UNICODE_STRING_DATA. >+ */ >+ protected byte getMessageType() { >+ return _messageHeader[9]; >+ >+ } >+ >+ /** >+ * Check the message magic number. If the magic number is incorrect we need to go into recovery mode >+ */ >+ protected boolean checkMessageMagic() { >+ return true; >+ } >+ >+ /** >+ * Recursively process a buffer of raw data. >+ */ >+ protected int processData(byte[] data, int offset, int limit, InetAddress addr) { >+ long messageLength; >+ byte type; >+ int current; >+ >+ current = offset; >+ >+ /* Is there data to process */ >+ if (offset >= limit) { >+ return limit; >+ } >+ >+ /* Is this a new message? */ >+ if (_currentHeaderOffset < MESSAGE_HEADER_LENGTH) { >+ /* Load the message header */ >+ current = this.loadMessageHeader(data, current, limit); >+ >+ /* Did we get the entire header, if not return */ >+ if (current == limit) { >+ return current; >+ } >+ >+ /* Resize and compress the forward buffer if nessesary */ >+ if (getMessageLength() >= _currentBufferSize) { >+ type = getMessageType(); >+ >+ if (type == BINARY_DATA || type == UTF8_STRING_DATA) { >+ byte[] replacement = new byte[(int) getMessageLength()]; >+ /* Shift the available data to the front of the buffer */ >+ System.arraycopy(data, current, replacement, 0, (limit - current)); >+ _bytesWritten = limit - current; >+ _binaryForwardBuffer = replacement; >+ } else { >+ char[] replacement = new char[(int) getMessageLength()]; >+ /* Shift the available data to the front of the buffer */ >+ for (int i = 0; i < limit - current + 1; i++) { >+ try { >+ replacement[i] = (char) data[i + current]; >+ } catch (Exception e) { >+ System.out.println("BufferFlusher.processData(): replacement[i]=(char)data[i+current];"); >+ System.out.println("BufferFlusher.processData(): repalcement.length=" + replacement.length + ", data.length=" + data.length + ", i=" + i + ", current=" + current); >+ e.printStackTrace(System.out); >+ throw new RuntimeException(e); >+ } >+ } >+ _bytesWritten = limit - current; >+ _stringForwardBuffer = replacement; >+ } >+ return limit; >+ } >+ } >+ >+ /* >+ * Validate the message header, if we are in recovery mode try and look at the next offset >+ */ >+ if (!checkMessageMagic()) { >+ System.out.println("BufferFlusher.processData(): Corrupt data"); >+ _currentHeaderOffset = 0; >+ return processData(data, offset + 1, limit, addr); >+ >+ } >+ >+ /* How long is the current message */ >+ messageLength = getMessageLength(); >+ >+ /* What is the message type */ >+ type = getMessageType(); >+ >+ /* Process the entire buffer */ >+ while (current < limit) { >+ >+ if (type == BINARY_DATA || type == UTF8_STRING_DATA) { >+ /* Copy as many bytes as possible into the forwarding buffer */ >+ while (current < limit && _bytesWritten < messageLength) { >+ _binaryForwardBuffer[_bytesWritten++] = data[current++]; >+ } >+ /* Are we at the end of the message? If so forward to the handler */ >+ if (_bytesWritten == messageLength) { >+ _processor.incommingData(_binaryForwardBuffer, _bytesWritten, addr); >+ _bytesWritten = 0; >+ _currentHeaderOffset = 0; >+ /* Continue processing this data buffer */ >+ current = this.processData(data, current, limit, addr); >+ } >+ } else if (type == UNICODE_STRING_DATA) { >+ /* Copy as many bytes as possible into the forwarding buffer */ >+ while (offset < limit && _bytesWritten < messageLength) { >+ _stringForwardBuffer[_bytesWritten >> 1] = (char) ((char) data[current++] | (char) (data[current++] << 8)); >+ _bytesWritten += 2; >+ } >+ /* Are we at the end of the message? If so forward to the handler */ >+ if (_bytesWritten == messageLength) { >+ _processor.incommingData(_stringForwardBuffer, _bytesWritten, addr); >+ _bytesWritten = 0; >+ _currentHeaderOffset = 0; >+ /* Continue processing this data buffer */ >+ current = this.processData(data, current, limit, addr); >+ } >+ } else { >+ /* Invalid message type */ >+ /* Copy as many bytes as possible into the forwarding buffer */ >+ while (offset < limit && _bytesWritten < messageLength) { >+ _binaryForwardBuffer[_bytesWritten++] = data[current++]; >+ } >+ /* Are we at the end of the message? If so forward to the handler */ >+ if (_bytesWritten == messageLength) { >+ _processor.incommingData(_binaryForwardBuffer, _bytesWritten, addr); >+ _bytesWritten = 0; >+ _currentHeaderOffset = 0; >+ /* Continue processing this data buffer */ >+ current = this.processData(data, current, limit, addr); >+ } >+ } >+ } >+ return current; >+ } >+ >+ public void run() { >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ MESSAGE_VALUE_ID = MESSAGE_VALUE_ID + "_" + this.hashCode(); >+ } >+ // outer: while(isProcessing() || (_currentFullBuffers != 0) || _isFinished == false) { /* 237169 make sure buffer is empty before exiting */ >+ outer: while (isProcessing() || (_currentFullBuffers != 0)) { // Bug 90153 >+ /* If there are no current buffers to empty wait */ >+ if (_currentFullBuffers == 0) { >+ _processor.waitingForData(); >+ do { >+ synchronized (_bufferArray[0]) { >+ try { >+ _bufferArray[0].wait(1000); >+ } catch (InterruptedException e) { >+ return; >+ } >+ } >+ if (!isProcessing() && _currentFullBuffers == 0) { >+ break outer; >+ } >+ } while (_currentFullBuffers == 0); >+ } >+ >+ /* Empty the current buffer */ >+ if (_bufferArray[_currentFlusherBuffer].length > 0) { >+ // System.out.println("---- Flushing "+ _bufferArray[_currentFlusherBuffer].length+" bytes from _bufferArray["+_currentFlusherBuffer+"]"); >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID, _bufferArray[_currentFlusherBuffer].data, 0, _bufferArray[_currentFlusherBuffer].length); >+ } >+ processData(_bufferArray[_currentFlusherBuffer].data, 0, _bufferArray[_currentFlusherBuffer].length, _bufferArray[_currentFlusherBuffer].addr); >+ /* Mark the buffer as empty */ >+ _bufferArray[_currentFlusherBuffer].length = 0; >+ >+ } >+ >+ synchronized (_bufferArray[0]) { >+ >+ _currentFullBuffers--; >+ >+ /* Increment the flusher to the next buffer */ >+ _currentFlusherBuffer++; >+ if (_currentFlusherBuffer == NUM_BUFFERS) { >+ _currentFlusherBuffer = 0; >+ } >+ >+ /* >+ * If the buffers were half full before this flush notify the filler it can continue. Generally this could be NUMBUFFERS but not as efficient as more thread switches happen >+ */ >+ if (_currentFullBuffers == 0) { >+ _bufferArray[0].notifyAll(); >+ } >+ } >+ } >+ >+ /* Notify that the flusher is exiting */ >+ // System.out.println("Notify that the flusher is exiting!!!"); >+ // System.out.println("isProcessing() = "+isProcessing()+", _currentFullBuffers = " +_currentFullBuffers); >+ if (_processor instanceof DataServerListener) { >+ ((DataServerListener) _processor).dataServerExited(); >+ } >+ } >+ >+ public void shutdown() { >+ // interrupt(); // Bug 90153 >+ } >+ >+ } /* end class RingBufferFiller */ >+ >+ /** >+ * >+ * @author slavescu >+ * >+ */ >+ class TCPDataProcessorNew extends TCPDataProcessor { >+ protected ExtendedDataServerListener _extendedProcessor; >+ protected DataProcessor _processor; >+ // protected int _currentProcessingOffset; >+ protected InetAddress _currentBufferAddr; >+ protected byte[] _currentBufferData; >+ protected int _currentBufferLength; >+ protected long _currentMessageLength; >+ protected byte _currentMessageType; >+ protected int _currentHeaderOffset; >+ protected char[] _stringForwardBuffer; >+ protected byte[] _binaryForwardBuffer; >+ protected int _bytesWritten; >+ protected int _bytesRead; >+ protected boolean _useExtendedProcessor; >+ protected int _processed; >+ protected byte[] _copyBuffer; // used only when the processor doesn't implement ExtendedDataServerListener >+ protected boolean crimsonParser; >+ protected boolean breakOuter; >+ protected byte[] _inputStreamModeBuffer; >+ protected int _inputStreamModeBufferLength, _inputStreamModeRecieverBufferLength; >+ protected int _inputStreamModeBufferPos; >+ >+ public TCPDataProcessorNew() { >+ super(); >+ } >+ >+ public void run() { >+ crimsonParser = isCrimsonParser(); >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ MESSAGE_VALUE_ID = MESSAGE_VALUE_ID + "_newDataProcessor_debugMessageValue_" + this.hashCode(); >+ } >+ // else >+ // if(CommunicationDebug.INSTANCE.debugSocketInputStream) >+ // { >+ // MESSAGE_VALUE_ID=MESSAGE_VALUE_ID+"_newDataProcessor_debugSocketInputStream"+this.hashCode(); >+ // } >+ >+ _isDataServerRunning = true; // Bug 90153 >+ _currentBufferData = new byte[BUFFER_SIZE]; >+ initLocalVariables(); >+ if (_processor instanceof ExtendedDataServerListener) { >+ _useExtendedProcessor = true; >+ _extendedProcessor = (ExtendedDataServerListener) _processor; >+ } else >+ _copyBuffer = new byte[BUFFER_SIZE]; >+ >+ /* Run forever */ >+ outer: while (!_shutdown && _isDataServerRunning) { /* 9707 */ >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServerNew.run(): step outer while loop!"); >+ } >+ if (isProcessing()) { >+ _dataConnection.create(); >+ InputStream is; >+ do { >+ is = _dataConnection.getInputStream(); >+ if (is == null) { >+ try { >+ Thread.sleep(1000); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ } >+ } >+ } while (!_shutdown && (is == null)); >+ >+ if (_shutdown) { >+ return; >+ } >+ >+ _currentBufferAddr = _dataConnection.getAddress(); >+ >+ if (!CommunicationDebug.INSTANCE.debugUseEventMode && _useExtendedProcessor && !crimsonParser) { >+ _inputStreamModeBuffer = new byte[BUFFER_SIZE]; >+ final InputStream delegatedInputStream = is; >+ InputStream isFiltered = new InputStream() { >+ byte[] oneByte = new byte[1]; >+ >+ public int available() throws IOException { >+ return delegatedInputStream.available(); >+ } >+ >+ public void close() throws IOException { >+ delegatedInputStream.close(); >+ } >+ >+ public synchronized void mark(int readlimit) { >+ delegatedInputStream.mark(readlimit); >+ } >+ >+ public boolean markSupported() { >+ return delegatedInputStream.markSupported(); >+ } >+ >+ public int read(byte[] b) throws IOException { >+ return read(b, 0, b.length); >+ } >+ >+ public synchronized void reset() throws IOException { >+ delegatedInputStream.reset(); >+ } >+ >+ public long skip(long n) throws IOException { >+ return delegatedInputStream.skip(n); >+ } >+ >+ public synchronized int read(byte[] b, int off, int len) throws IOException { >+ while (true) { >+ if (_inputStreamModeBufferPos != _inputStreamModeBufferLength) { >+ int ret = copyInputData(b, off, len); >+ return ret; >+ } else { >+ _inputStreamModeBufferPos = 0; >+ _inputStreamModeBufferLength = 0; >+ } >+ >+ if (_currentBufferLength == _currentBufferData.length) { >+ breakOuter = false; >+ extendBuffer(); >+ if (breakOuter) >+ return -1; >+ } >+ _bytesRead = delegatedInputStream.read(_currentBufferData, _currentBufferLength, _currentBufferData.length - _currentBufferLength); >+ if (_bytesRead > 0) { >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID, _currentBufferData, _currentBufferLength, _bytesRead); >+ } >+ _currentBufferLength += _bytesRead; >+ // check if the header was received >+ if (_currentBufferLength > MESSAGE_HEADER_LENGTH) { >+ processCurrentBuffer(); >+ int ret = copyInputData(b, off, len); >+ if (ret == 0) >+ continue; >+ return ret; >+ } >+ } else if (_bytesRead < 0) { >+ /* The connection is closed */ >+ done(_dataConnection); >+ return -1; >+ } >+ return 0; >+ } >+ } >+ >+ protected int copyInputData(byte[] b, int off, int len) { >+ int ret = 0; >+ len = Math.min(len, _inputStreamModeBufferLength - _inputStreamModeBufferPos); >+ System.arraycopy(_inputStreamModeBuffer, _inputStreamModeBufferPos, b, off, len); >+ // if(CommunicationDebug.INSTANCE.debugMessageValue) >+ // { >+ // CommunicationDebug.INSTANCE.writeBinaryLog("incommingData", b,off,len); >+ // } >+ _inputStreamModeBufferPos += len; >+ return ret + len; >+ } >+ >+ public int read() throws IOException { >+ if (read(oneByte, 0, 1) == -1) >+ return -1; >+ else >+ return oneByte[0]; >+ } >+ }; >+ try { >+ _extendedProcessor.incommingStream(isFiltered, _currentBufferAddr); >+ } catch (Exception e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessorNew.run() - _extendedProcessor.incommingStream ended with exception, " + _extendedProcessor); >+ e.printStackTrace(System.out); >+ } >+ done(_dataConnection); >+ break outer; >+ } >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessorNew.run() - _extendedProcessor.incommingStream ended, " + _extendedProcessor); >+ } >+ } else >+ while (true) { >+ try { >+ // if(CommunicationDebug.INSTANCE.debugSocketInputStream) >+ // { >+ // _bytesRead = is.read(_currentBuffer.data, 0, _currentBuffer.data.length); >+ // if(_bytesRead>0) >+ // CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID,_currentBuffer.data,0,_bytesRead); >+ // else { >+ // /* The connection is closed */ >+ // done(incommingConnection); >+ // break outer; >+ // } >+ // } >+ // else >+ // { >+ if (_processed != 0 && _currentMessageLength > Integer.MAX_VALUE) { >+ _currentHeaderOffset = 0; >+ recover(); >+ continue; >+ } else { >+ if (_currentBufferLength == _currentBufferData.length) { >+ breakOuter = false; >+ extendBuffer(); >+ if (breakOuter) >+ break outer; >+ } >+ // if(CommunicationDebug.INSTANCE.debug) >+ // { >+ // System.out.println("TCPDataProcessorNew.run() - about to read _currentBufferData.length - _currentBufferLength="+(_currentBufferData.length - _currentBufferLength)); >+ // } >+ _bytesRead = is.read(_currentBufferData, _currentBufferLength, _currentBufferData.length - _currentBufferLength); >+ // if(CommunicationDebug.INSTANCE.debug) >+ // { >+ // System.out.println("TCPDataProcessorNew.run() - bytesRead="+_bytesRead); >+ // } >+ if (_bytesRead > 0) { >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID, _currentBufferData, _currentBufferLength, _bytesRead); >+ } >+ _currentBufferLength += _bytesRead; >+ // check if the header was received >+ if (_currentBufferLength > MESSAGE_HEADER_LENGTH) { >+ _processed = 0; >+ processCurrentBuffer(); >+ } >+ } else if (_bytesRead < 0) { >+ /* The connection is closed */ >+ done(_dataConnection); >+ break outer; >+ } >+ } >+ // } >+ } catch (InterruptedIOException e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessorNew.run() - timeout e.bytesTransferred=" + e.bytesTransferred); >+ e.printStackTrace(System.out); >+ } >+ /* Read timeout, don't want to wait too long */ >+ /* This is used to terminate the thread if the process is killed abnormally */ >+ if (e.bytesTransferred > 0) { >+ _bytesRead = e.bytesTransferred; >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID, _currentBufferData, _currentBufferLength, _bytesRead); >+ } >+ _currentBufferLength += _bytesRead; >+ // check if the header was received >+ if (_currentBufferLength > MESSAGE_HEADER_LENGTH) { >+ _processed = 0; >+ processCurrentBuffer(); >+ } >+ >+ } >+ // else >+ // if(_shutdown) >+ // { >+ // /* The connection is closed */ >+ // done(incommingConnection); >+ // break outer; >+ // } >+ } catch (IOException e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ e.printStackTrace(System.out); >+ } >+ done(_dataConnection); >+ break outer; >+ } >+ >+ } >+ } else { >+ try { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessorNew.run() - Monitoring is stopped, keep this thread in sleep state !"); >+ } >+ /* Monitoring is stopped, keep this thread in sleep state */ >+ sleep(1000); /* 9707 */ >+ } catch (InterruptedException e) { >+ } >+ } >+ } >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServerNew.run(): exited outter while loop!"); >+ } >+ >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataProcessorNew.run() - Close socket !"); >+ } >+ _dataConnection.destroyConnection(); >+ >+ if (_processor instanceof DataServerListener) { >+ ((DataServerListener) _processor).dataServerExited(); >+ } >+ if (CommunicationDebug.INSTANCE.debugMessageValue) { >+ >+ try { >+ CommunicationDebug.INSTANCE.getBinaryLog(MESSAGE_VALUE_ID).flush(); >+ CommunicationDebug.INSTANCE.removeBinaryLog(MESSAGE_VALUE_ID); >+ } catch (IOException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ >+ } >+ >+ private void extendBuffer() { >+ int remainingData = _currentBufferLength - _currentHeaderOffset; >+ if (_currentMessageLength > _currentBufferLength - MESSAGE_HEADER_LENGTH) { >+ // grow to _currentMessageLength+MESSAGE_HEADER_LENGTH >+ byte[] b = null; >+ try { >+ b = new byte[(int) _currentMessageLength + MESSAGE_HEADER_LENGTH]; >+ } catch (Throwable e) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("_currentHeaderOffset=" + _currentHeaderOffset); >+ System.out.println("_currentBufferLength=" + _currentBufferLength); >+ System.out.println("getMessageLength()=" + getMessageLength()); >+ System.out.println("getMessageType()=" + getMessageType()); >+ e.printStackTrace(System.out); >+ // dump current buffer in a separate file >+ CommunicationDebug.INSTANCE.writeBinaryLog(MESSAGE_VALUE_ID + "_" + _currentHeaderOffset, _currentBufferData, 0, _currentBufferLength); >+ } >+ // recover(); >+ // continue; >+ breakOuter = true; >+ return; >+ } >+ // copy remainig data to new location >+ System.arraycopy(_currentBufferData, _currentHeaderOffset, b, 0, _currentBufferLength - _currentHeaderOffset); >+ _currentBufferData = b; >+ } else { >+ if (remainingData < _currentHeaderOffset) { >+ // shift remainig data to the begining of the buffer >+ System.arraycopy(_currentBufferData, _currentHeaderOffset, _currentBufferData, 0, remainingData); >+ } else { >+ // shift remainig data to the begining of the buffer >+ for (int i = 0; i < remainingData; i++) { >+ _currentBufferData[i] = _currentBufferData[i + _currentHeaderOffset]; >+ } >+ } >+ } >+ _currentBufferLength = remainingData; >+ _currentHeaderOffset = 0; >+ } >+ >+ protected boolean isCrimsonParser() { >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ try { >+ SAXParser p = factory.newSAXParser(); >+ ; >+ if (p != null && p.getClass().getName().equals("org.apache.crimson.jaxp.SAXParserImpl")) { >+ return true; >+ } >+ } catch (Exception e) { >+ } >+ return false; >+ } >+ >+ private void done(DataConnection connection) { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServerNew.done(): entered - " + this); >+ } >+ /* Socket is toast or connection closed , we are done */ >+ pauseProcessing(); >+ _isDataServerRunning = false; // Bug 90153 >+ connection.destroyConnection(); /* 9707 */ >+ if (CommunicationDebug.INSTANCE.debug) { >+ new Throwable("TCPDataServerNew.done(): Connection closed ! " + this).printStackTrace(System.out); >+ } >+ } >+ >+ protected int recover() { >+ _currentHeaderOffset++; >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServerNew.recover(): _currentHeaderOffset = " + _currentHeaderOffset); >+ } >+ // incorrect length, try to recover >+ if (_currentHeaderOffset == _currentBufferLength) { >+ // ignore this buffer and continue reading >+ initLocalVariables(); >+ _currentHeaderOffset = 0; >+ } else { >+ _currentMessageLength = -1; >+ _processed = 0; >+ // process from new possition >+ processCurrentBuffer(); >+ } >+ return _currentHeaderOffset; >+ } >+ >+ private void initLocalVariables() { >+ _currentHeaderOffset = 0; >+ _currentMessageLength = -1; >+ _bytesRead = 0; >+ _bytesWritten = 0; >+ _currentBufferLength = 0; >+ _processed = 0; >+ } >+ >+ public void setProcessor(DataProcessor processor) { >+ if (_processor instanceof ExtendedDataServerListener) { >+ _useExtendedProcessor = true; >+ _extendedProcessor = (ExtendedDataServerListener) _processor; >+ } else { >+ _useExtendedProcessor = false; >+ this._processor = processor; >+ if (_copyBuffer == null) >+ _copyBuffer = new byte[BUFFER_SIZE]; >+ } >+ } >+ >+ /** >+ * Get the length of the current message >+ */ >+ protected long getMessageLength() { >+ return Message.readRALongFromBuffer(_currentBufferData, _currentHeaderOffset + 5); >+ } >+ >+ /** >+ * Get the message type. There are currently three types of messages. BINARY_DATA, UTF8_STRING_DATA, UNICODE_STRING_DATA. >+ */ >+ protected byte getMessageType() { >+ return _currentBufferData[_currentHeaderOffset + 9]; >+ } >+ >+ /** >+ * Check the message magic number. If the magic number is incorrect we need to go into recovery mode >+ */ >+ protected boolean checkMessageMagic() { >+ // /* Check the message magic number */ >+ // long messageKey = (long) (_currentBufferData[_currentHeaderOffset] << 24 & 0xff000000) | >+ // (long) (_currentBufferData[_currentHeaderOffset + 1] << 16 & 0x00ff0000) | >+ // (long) _currentBufferData[_currentHeaderOffset + 2] << 8 & 0x0000ff00 | >+ // (long) _currentBufferData[_currentHeaderOffset + 3]; >+ // /* If the magic is incorect we need to go into recovery mode */ >+ // /* TO_DO: RE-enable and test*/ >+ // if (messageKey == RA_MAGIC ) { >+ // return false; >+ // } >+ // return Message.readRALongFromBuffer(_currentBufferData, _currentHeaderOffset) == RA_MAGIC ; >+ if (_currentBufferData[_currentHeaderOffset] != RA_MAGIC_0) >+ return false; >+ if (_currentBufferData[_currentHeaderOffset + 1] != RA_MAGIC_1) >+ return false; >+ if (_currentBufferData[_currentHeaderOffset + 2] != RA_MAGIC_2) >+ return false; >+ if (_currentBufferData[_currentHeaderOffset + 3] != RA_MAGIC_3) >+ return false; >+ return true; >+ } >+ >+ /** >+ * process the current input buffer and sends all the full messages to the data processor >+ */ >+ protected void processCurrentBuffer() { >+ /* Is there data to process */ >+ if (_currentBufferLength <= 0) { >+ _processed = 0; >+ return; >+ } >+ int _stopProcessingMarker = _currentBufferLength - MESSAGE_HEADER_LENGTH; >+ do { >+ if (_currentMessageLength < 0) { >+ /* Validate the message header */ >+ do { >+ if (_currentHeaderOffset > _stopProcessingMarker) { >+ _processed = 0; >+ return; >+ } >+ if (checkMessageMagic()) { >+ break; >+ } >+ // recovery mode, try and look at the next offset >+ if (CommunicationDebug.INSTANCE.debug) >+ System.out.println("TCPDataServerNew.processCurrentBuffer() - Invalid magic number in header at: " + _currentHeaderOffset); >+ _currentHeaderOffset++; >+ } while (true); >+ _currentMessageLength = getMessageLength(); >+ _currentMessageType = getMessageType(); >+ } >+ if (_currentHeaderOffset + _currentMessageLength <= _stopProcessingMarker) { >+ _bytesWritten = writeMessage(_currentHeaderOffset, _currentBufferData); >+ _processed += _bytesWritten; >+ _currentHeaderOffset = _currentHeaderOffset + MESSAGE_HEADER_LENGTH + _bytesWritten; >+ // _currentMessageLength = -1; >+ } else { >+ return; >+ } >+ } while (true); >+ } >+ >+ /** >+ * sends a full message to the data processor >+ */ >+ protected int writeMessage(int _currentHeaderOffset, byte[] _currentBufferData) { >+ int _bytesWritten = 0; >+ if (_currentMessageType == UNICODE_STRING_DATA) { >+ int endOffset = _currentHeaderOffset + MESSAGE_HEADER_LENGTH + (int) _currentMessageLength; >+ for (int i = _currentHeaderOffset + MESSAGE_HEADER_LENGTH; i < endOffset;) { >+ _stringForwardBuffer[_bytesWritten >> 1] = (char) ((char) _currentBufferData[i++] | (char) (_currentBufferData[i++] << 8)); >+ _bytesWritten += 2; >+ >+ } >+ /* Are we at the end of the message? If so forward to the handler */ >+ if (_bytesWritten == _currentMessageLength) { >+ _processor.incommingData(_stringForwardBuffer, _bytesWritten, _currentBufferAddr); >+ _currentMessageLength = -1; >+ // _bytesWritten = 0; >+ // _currentHeaderOffset = 0; >+ // /* Continue processing this data buffer */ >+ // current = this.processData(data, current, limit, addr); >+ } >+ >+ } else { >+ _bytesWritten = (int) _currentMessageLength; >+ if (_useExtendedProcessor) { >+ if (!CommunicationDebug.INSTANCE.debugUseEventMode && !crimsonParser) { >+ if (_inputStreamModeBuffer.length - _inputStreamModeBufferLength < _bytesWritten) { >+ byte[] temp = new byte[_inputStreamModeBufferLength + _bytesWritten + 1024]; >+ System.arraycopy(_inputStreamModeBuffer, 0, temp, 0, _inputStreamModeBufferLength); >+ _inputStreamModeBuffer = temp; >+ } >+ System.arraycopy(_currentBufferData, _currentHeaderOffset + MESSAGE_HEADER_LENGTH, _inputStreamModeBuffer, _inputStreamModeBufferLength, _bytesWritten); >+ _inputStreamModeBufferLength += _bytesWritten; >+ } else >+ _extendedProcessor.incommingData(_currentBufferData, _currentHeaderOffset + MESSAGE_HEADER_LENGTH, _bytesWritten, _currentBufferAddr); >+ } else { >+ /* BINARY_DATA, UTF8_STRING_DATA or Invalid message type */ >+ /* Copy as many bytes as possible into the forwarding buffer */ >+ if (_copyBuffer.length < _bytesWritten) >+ _copyBuffer = new byte[_bytesWritten]; >+ System.arraycopy(_currentBufferData, _currentHeaderOffset + MESSAGE_HEADER_LENGTH, _copyBuffer, 0, _bytesWritten); >+ _processor.incommingData(_copyBuffer, _bytesWritten, _currentBufferAddr); >+ } >+ _currentMessageLength = -1; >+ } >+ return _bytesWritten; >+ } >+ >+ public void shutdown() { >+ if (CommunicationDebug.INSTANCE.debug) { >+ System.out.println("TCPDataServerNew.shutdown() - " + this); >+ } >+ _shutdown = true; >+ _dataConnection.destroyConnection(); >+ } >+ >+ } /* end class TCPDataProcessorNew */ >+ >+ public int getPort() { >+ return _port; >+ } >+ >+ public void startLocalServer(DataProcessor processor) throws IOException { >+ int instance = Integer.parseInt(_dataConnection.getConnectionId()); >+ startServer(processor, -instance); // pass in negative port for local direct instance name >+ } >+ >+ public void startServer(DataProcessor processor, int port) throws IOException { >+ if (!CommunicationDebug.INSTANCE.debugUseOldDataServer) { >+ startServerNew(processor, port); >+ } else { >+ /* Create the buffering mechanism */ >+ _bufferArray = new SingleBuffer[NUM_BUFFERS]; >+ for (int i = 0; i < NUM_BUFFERS; i++) >+ _bufferArray[i] = new SingleBuffer(); >+ >+ _port = _dataConnection.getPort(); >+ >+ _server = new TCPDataProcessor(); >+ _server.setName("TCPDataFiller"); >+ >+ /* Set up the data flusher */ >+ _flusher = new BufferFlusher(); >+ _flusher.setProcessor(processor); >+ _flusher.setName("TCPDataFlusher"); >+ >+ /* Don't block exit of the VM */ >+ _server.setDaemon(true); >+ _flusher.setDaemon(true); >+ >+ /* >+ * RKD: Because these two threads intensely contend for the same resources we need to increase the priority of the flusher, otherwise I have noticed that the flusher doesn't run often enough and the data sits in the buffers far too long. A relitive increase of 3 seems to much better >+ */ >+ >+ _flusher.setPriority(_server.getPriority() + 3); >+ >+ _server.start(); >+ _flusher.start(); >+ } >+ } >+ >+ private void startServerNew(DataProcessor processor, int port) throws IOException { >+ /* Create the buffering mechanism */ >+ _bufferArray = new SingleBuffer[NUM_BUFFERS]; >+ for (int i = 0; i < NUM_BUFFERS; i++) { >+ _bufferArray[i] = new SingleBuffer(); >+ } >+ >+ _server = new TCPDataProcessorNew(); >+ _server.setName("TCPDataFiller"); >+ ((TCPDataProcessorNew) _server).setProcessor(processor); >+ >+ /* Don't block exit of the VM */ >+ _server.setDaemon(true); >+ >+ _server.start(); >+ } >+ >+ public void startServer(DataProcessor processor) throws IOException { >+ startServer(processor, 0); >+ } >+ >+ public boolean isProcessing() { >+ return _isDataServerRunning; // Bug 90153 >+ // return _server.isAlive(); >+ } >+ >+ public void stopServer() { >+ _server.pauseProcessing(); /* 9707 */ >+ } >+ >+ /* 9707 */ >+ public void resumeServer() { >+ _server.resumeProcessing(); >+ } >+ >+ /* 9707 */ >+ public void resumeServer(DataProcessor processor) { >+ if (!CommunicationDebug.INSTANCE.debugUseOldDataServer) { >+ resumeServerNew(processor); >+ } else { >+ _flusher.setProcessor(processor); >+ _server.resumeProcessing(); >+ } >+ } >+ >+ private void resumeServerNew(DataProcessor processor) { >+ _server.resumeProcessing(); >+ ((TCPDataProcessorNew) _server).setProcessor(processor); >+ } >+ >+ /* 9707 */ >+ public void shutdownServer() { >+ // System.out.println("TCPDataServer is shutted down!"); >+ if (!CommunicationDebug.INSTANCE.debugUseOldDataServer) { >+ shutdownServerNew(); >+ } else { >+ _server.shutdown(); >+ _flusher.shutdown(); >+ } >+ } >+ >+ private void shutdownServerNew() { >+ _server.shutdown(); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentDetailsCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentDetailsCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentDetailsCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentDetailsCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentDetailsCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentDetailsCommand extends DetailedAgentInfoCommand { >+ >+ /** >+ * ReadyVMCommand constructor comment. >+ */ >+ public AgentDetailsCommand() { >+ super(); >+ _tag = RA_AGENT_DETAILS; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ProcessActiveException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ProcessActiveException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ProcessActiveException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ProcessActiveException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessActiveException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class ProcessActiveException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = -6533768583180265869L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/DetachFromAgentCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/DetachFromAgentCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/DetachFromAgentCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/DetachFromAgentCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DetachFromAgentCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class DetachFromAgentCommand extends SimpleAgentInfoCommand { >+ >+ /** >+ * DetachFromCommand constructor comment. >+ */ >+ public DetachFromAgentCommand() { >+ super(); >+ _tag = RA_DETACH_FROM_AGENT; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/RAInetAddress.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/RAInetAddress.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/RAInetAddress.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/RAInetAddress.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: RAInetAddress.java,v 1.3 2005/04/05 15:48:58 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+import java.net.UnknownHostException; >+ >+public class RAInetAddress implements Constants { >+ >+ protected byte[] _data = null; >+ protected int _length = 0; >+ protected InetAddress _address = null; >+ >+ public RAInetAddress() { >+ super(); >+ } >+ >+ public int getLength() { >+ return _length; >+ } >+ >+ public void setLength(int length) { >+ _length = length; >+ } >+ >+ public void setData(byte[] data) { >+ _data = data; >+ } >+ >+ public int getSize() { >+ return sizeofByte + _length; >+ } >+ >+ public InetAddress getAddress() throws UnknownHostException { >+ /* Check our cache */ >+ if (_address != null) { >+ return _address; >+ } >+ >+ if (_length == 0) { >+ return null; >+ } >+ /* Build a string representing the IP address in decimal form */ >+ String addr = new String(); >+ addr += Byte.toString(_data[0]); >+ for (int i = 1; i < _length; i++) { >+ addr = addr + "." + Byte.toString(_data[i]); >+ } >+ >+ /* Lookup all the InetAddress objects for this address */ >+ InetAddress addrs = InetAddress.getByName(addr); >+ >+ /* >+ * Search for our match: RKD: This was removed aswe probablydon't need all the addresses. for(int j=0; j<addrs.length; j++) { if(addrs[j].getHostAddress().equals(addr)) { _address=addrs[j]; return _address; } } return null >+ */ >+ >+ return addrs; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Variable.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Variable.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Variable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Variable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Variable.java,v 1.3 2005/04/05 15:48:58 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+/** >+ * A Variable maps to an instance of a environment variable >+ */ >+public class Variable { >+ private String _name = null; >+ private String _value = null; >+ >+ /** >+ * Create an environment variable with the specified name value pair. >+ */ >+ public Variable(String name, String value) { >+ _name = name; >+ _value = value; >+ } >+ >+ /** >+ * Retrieve the name of this environment variable. >+ */ >+ public String getName() { >+ return _name; >+ } >+ >+ /** >+ * Retrieve the value of this environment variable. >+ */ >+ public String getValue() { >+ return _value; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentPeerListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentPeerListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentPeerListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentPeerListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentPeerListener.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public interface AgentPeerListener extends AgentListener { >+ >+ /** >+ * Invoked when an agent requests to be monitored because this client is currently monitoring another agent. >+ */ >+ void peerWaiting(Agent agent, Agent peer); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringRemoteAgentCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringRemoteAgentCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringRemoteAgentCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringRemoteAgentCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,117 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: StartMonitoringRemoteAgentCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.net.InetAddress; >+ >+public class StartMonitoringRemoteAgentCommand extends SimpleAgentInfoCommand { >+ >+ protected long _port = 0; >+ protected long _ip = 0; >+ >+ /** >+ * SetMonitorCommandEntry constructor comment. >+ */ >+ public StartMonitoringRemoteAgentCommand() { >+ super(); >+ _tag = RA_START_MONITORING_AGENT_REMOTE; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/3/00 11:06:34 AM) >+ */ >+ public long getIP() { >+ return _ip; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 12:23:51 PM) >+ * >+ * @return short >+ */ >+ public long getPort() { >+ return _port; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 12:58:48 PM) >+ * >+ * @return int >+ */ >+ public int getSize() { >+ return super.getSize() + 2 * sizeofLong; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 9:25:14 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param length >+ * int[] >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ >+ _ip = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ _port = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/3/00 11:06:19 AM) >+ * >+ * @param param >+ * java.net.InetAddress >+ */ >+ public void setInetAddress(InetAddress param) { >+ byte[] addr_bytes = param.getAddress(); >+ _ip = 0; >+ _ip += (addr_bytes[3] << 24) & (0xFF000000); >+ _ip += (addr_bytes[2] << 16) & (0x00FF0000); >+ _ip += (addr_bytes[1] << 8) & (0x0000FF00); >+ _ip += (addr_bytes[0]) & (0x000000FF); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (6/8/00 12:23:41 PM) >+ * >+ * @param port >+ * short >+ */ >+ public void setPort(short port) { >+ _port = port; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (7/21/00 3:41:09 PM) >+ * >+ * @return int >+ * @param buffer >+ * byte[] >+ * @param offset >+ * int >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRALongToBuffer(buffer, current, _ip); >+ current = Message.writeRALongToBuffer(buffer, current, _port); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ConsoleNotStartedException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ConsoleNotStartedException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ConsoleNotStartedException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ConsoleNotStartedException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ConsoleNotStartedException.java,v 1.4 2005/10/08 14:28:53 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ConsoleNotStartedException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = -3830340454438462679L; >+ >+ /** >+ * ConsoleNotStartedException constructor comment. >+ */ >+ public ConsoleNotStartedException() { >+ super(); >+ } >+ >+ /** >+ * ConsoleNotStartedException constructor comment. >+ * >+ * @param s >+ * java.lang.String >+ */ >+ public ConsoleNotStartedException(String s) { >+ super(s); >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/NodeImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/NodeImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/NodeImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/NodeImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,776 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: NodeImpl.java,v 1.20 2006/12/14 23:11:18 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.net.InetAddress; >+import java.net.InetSocketAddress; >+import java.net.ServerSocket; >+import java.net.UnknownHostException; >+import java.util.Enumeration; >+import java.util.Hashtable; >+ >+import org.eclipse.hyades.execution.security.ISecureClientParameters; >+import org.eclipse.hyades.execution.local.common.ActiveAgentListCommand; >+import org.eclipse.hyades.execution.local.common.AgentDetailsCommand; >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.local.common.GetPropertyListCommand; >+import org.eclipse.hyades.execution.local.common.KillProcessCommand; >+import org.eclipse.hyades.execution.local.common.MonitorPeerRequestCommand; >+import org.eclipse.hyades.execution.local.common.PropertyListCommand; >+import org.eclipse.hyades.execution.local.common.QueryAgentDetailsCommand; >+import org.eclipse.hyades.execution.local.common.QueryAgentListCommand; >+import org.eclipse.hyades.execution.local.common.QueryProcessListCommand; >+import org.eclipse.hyades.execution.local.common.RegisteredProcessListCommand; >+import org.eclipse.hyades.execution.local.common.SetNVPairCommand; >+import org.eclipse.hyades.execution.local.common.SimpleProcessCommand; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+import org.eclipse.hyades.execution.security.User; >+import org.eclipse.tptp.platform.agentcontroller.internal.AgentControllerConstants; >+import org.eclipse.tptp.platform.agentcontroller.internal.impl.AgentControllerFactoryImpl; >+ >+public class NodeImpl implements Node, Constants { >+ private static int DEFAULT_TIMEOUT = 15000; // 15 sec >+ >+ private String _name; >+ >+ private InetAddress[] _addr; >+ >+ private Connection _connection; >+ >+ private Application _application; >+ >+ private Hashtable _processList = new Hashtable(256); >+ >+ private SetNVPairCommand[] props = null; >+ >+ // Local listeners and handlers >+ private InnerProcessListener _processListener = new InnerProcessListener(); >+ >+ private InnerConnectionListener _connectionListener = new InnerConnectionListener(); >+ >+ private InnerCommandHandler _commandHandler = new InnerCommandHandler(); >+ >+ // Locks >+ private Object _processListLock = new Object(); >+ >+ private Object _agentListLock = new Object(); >+ >+ private Object _agentDetailsLock = new Object(); >+ >+ private Object _propertyListLock = new Object(); >+ >+ // >+ // Security related stuff >+ // >+ private boolean _isAuthenticated = false; >+ private int _authenticationTimeout = 10000; // 5 sec authentication timeout >+ private Object _authenticationLock = new Object(); >+ private User _user = null; >+ private ISecureClientParameters _securityParms = null; >+ >+ public NodeImpl(String name, InetAddress addr) { >+ super(); >+ _name = name; >+ >+ try { >+ _addr = InetAddress.getAllByName(addr.getHostName()); >+ } catch (UnknownHostException e) { >+ } >+ } >+ >+ public NodeImpl(String name, InetAddress[] addr) { >+ super(); >+ _name = name; >+ _addr = addr; >+ } >+ >+ /** >+ * @see Node#killProcess(Process) >+ */ >+ public void killProcess(Process process) throws InactiveProcessException, NotConnectedException { >+ /* Determine if we have a connection */ >+ if (_connection == null) { >+ throw new NotConnectedException(); >+ } >+ >+ /* Determine if the process is active */ >+ if (!process.isActive()) { >+ throw new InactiveProcessException(); >+ } >+ >+ /* Kill the process */ >+ ControlMessage message = new ControlMessage(); >+ KillProcessCommand command = new KillProcessCommand(); >+ command.setProcessId(Long.parseLong(process.getProcessId())); >+ message.appendCommand(command); >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ } catch (IOException e) { >+ // TODO Auto-generated catch block >+ } >+ } >+ >+ /** >+ * @see Node#shutdown(long) >+ */ >+ public void shutdown(long delay) throws NotConnectedException { >+ throw new NotImplementedException(); >+ } >+ >+ /** >+ * @see Node#reboot(long) >+ */ >+ public void reboot(long delay) throws NotConnectedException { >+ throw new NotImplementedException(); >+ } >+ >+ /** >+ * @see Node#listMonitors() >+ */ >+ public Enumeration listMonitors() throws NotConnectedException { >+ throw new NotImplementedException(); >+ } >+ >+ /** >+ * List the processes running in the node >+ * >+ * This method has side effects of setting the _processList member variable, populating the agents within each process in _processList and retrieving the details of each agent in each process. >+ */ >+ public Enumeration listProcesses() throws NotConnectedException { >+ ControlMessage message; >+ >+ if (_connection == null) { >+ throw new NotConnectedException(); >+ } else { >+ _connection.addConnectionListener(_connectionListener); // to avoid >+ // deadlock >+ >+ // Query the process list >+ message = new ControlMessage(); >+ QueryProcessListCommand qplCommand = new QueryProcessListCommand(); >+ message.appendCommand(qplCommand); >+ synchronized (_processListLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _processListLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ return null; >+ } >+ } >+ >+ // Populate the process with all agents >+ Enumeration ePIDs = _processList.keys(); >+ while (ePIDs.hasMoreElements()) { >+ Long pid = (Long) (ePIDs.nextElement()); >+ Process p = (ProcessImpl) _processList.get(pid); >+ >+ // Query the agent list >+ message = new ControlMessage(); >+ QueryAgentListCommand qalCommand = new QueryAgentListCommand(); >+ qalCommand.setProcessId(pid.longValue()); >+ message.appendCommand(qalCommand); >+ synchronized (_agentListLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _agentListLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ return null; >+ } >+ } >+ >+ // Populate the agent details >+ Enumeration eAgents = p.listAgents(); >+ while (eAgents.hasMoreElements()) { >+ Agent ag = (Agent) eAgents.nextElement(); >+ String agentName = ag.getName(); >+ >+ message = new ControlMessage(); >+ QueryAgentDetailsCommand qadCommand = new QueryAgentDetailsCommand(); >+ qadCommand.setProcessId(pid.longValue()); >+ qadCommand.setAgentName(agentName); >+ message.appendCommand(qadCommand); >+ synchronized (_agentDetailsLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _agentDetailsLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ return null; >+ } >+ } >+ } >+ } >+ } >+ >+ return _processList.elements(); >+ } >+ >+ /** >+ * @see Node#getProcess() >+ */ >+ public synchronized Process getProcess(String processId) { >+ return (Process) _processList.get(new Long(processId)); >+ } >+ >+ /** >+ * @see Node#getInetAddress() >+ */ >+ public InetAddress getInetAddress() { >+ if (_addr != null) { >+ return _addr[0]; >+ } >+ >+ return null; >+ } >+ >+ /** >+ * @see Node#getAllInetAddresses() >+ */ >+ public InetAddress[] getAllInetAddresses() { >+ return _addr; >+ } >+ >+ /** >+ * @see Node#getName() >+ */ >+ public String getName() { >+ return _name; >+ } >+ >+ /** >+ * @see Node#isConnected() >+ */ >+ public boolean isConnected() { >+ if (_connection != null) { >+ return _connection.isActive(); >+ } >+ return false; >+ } >+ >+ /** >+ * @see Node#connect() >+ */ >+ public synchronized Connection connect(int port) throws AgentControllerUnavailableException, SecureConnectionRequiredException, UntrustedAgentControllerException, LoginFailedException { >+ Connection testConnection = null; >+ >+ /* >+ * Will try to connect if: 1. There is no connection 2. There is a connection but it is not active 3. There is a connection but wants to test other connections as well >+ */ >+ int who = AgentControllerFactoryImpl.whoIsRunning(); >+ if (isLocal() && ((port <= 0) || ((port > 0) && (who != AgentControllerConstants.TPTP_RAC_RUNNING)))) { >+ >+ /* If someone has a RAC running but choose IAC, throw an exception */ >+ if (who == AgentControllerConstants.TPTP_RAC_RUNNING) { >+ throw new AgentControllerUnavailableException(); // Since IAC cannot be started if RAC is already running >+ } >+ >+ if (!AgentControllerFactoryImpl.getAgentController().isEnabled()) { >+ throw new AgentControllerUnavailableException(); // Since IAC is disabled by preference >+ } >+ >+ /* >+ * Start IAC if not already started >+ */ >+ AgentControllerFactoryImpl.getAgentController().start(); >+ >+ /* >+ * Reuse existing if there is ones, or it has a previously attached remote ConnectionImpl >+ */ >+ if ((_connection == null) || (_connection instanceof ConnectionImpl)) { >+ _connection = ConnectionFactory.getLocalConnection(this); >+ } >+ >+ /* >+ * Try connect >+ */ >+ if (!_connection.isActive()) { >+ try { >+ _connection.connect(this, 0); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ } >+ } else if ((_connection == null || !_connection.isActive() || (port != _connection.getPort()))) { // Bug >+ // 54320 >+ try { >+ >+ /* >+ * If the keystore is specified then we will try a secure connection >+ */ >+ if (_securityParms == null) { >+ testConnection = ConnectionFactory.getConnection(this); >+ testConnection.connect(this, port); >+ } else { >+ /* Look through our extension points for a security provider */ >+ testConnection = ConnectionFactory.getSecuredConnection(this); >+ if (testConnection != null) { >+ testConnection.connect(this, port); >+ } >+ } >+ >+ /* >+ * If there is no exception after calling connect() that means the connection with the specified port is valid. Since we assume a 1-to-1 association between Node and Connection, that means any previous connectio is invalid (otherwise the attempted connect() will fail). >+ */ >+ _connection = testConnection; >+ >+ } catch (IOException e) { >+ _connection = null; >+ throw new AgentControllerUnavailableException(); >+ } >+ } >+ >+ return _connection; >+ >+ } >+ >+ /** >+ * @see Node#getConnection() >+ */ >+ public Connection getConnection() { >+ if (_connection == null) { >+ return null; >+ } >+ >+ if (!_connection.isActive()) { >+ if (_connection instanceof LocalConnectionImpl) { >+ try { >+ _connection.connect(this, 0); >+ } catch (Exception e) { >+ } >+ } >+ } >+ return _connection; >+ } >+ >+ public ProcessListener getProcessListener() { >+ return _processListener; >+ } >+ >+ /** >+ * @see Node#setUser() >+ */ >+ public void setUser(User user) { >+ _user = user; >+ } >+ >+ /** >+ * @see Node#getUser() >+ */ >+ public User getUser() { >+ return _user; >+ } >+ >+ public void setApplication(Application app) { >+ _application = app; >+ } >+ >+ public Application getApplication() { >+ return _application; >+ } >+ >+ public void setSecurityParameters(ISecureClientParameters manager) { >+ _securityParms = manager; >+ } >+ >+ public ISecureClientParameters getSecurityParameters() { >+ return _securityParms; >+ } >+ >+ /** >+ * Bug 53938 >+ * >+ * Query the options specified in the Agent Controller's configuration file. >+ * >+ * @param name >+ * The name of the option >+ * @param type >+ * The type of the option >+ * @return An array of SetNVPairCommand objects >+ */ >+ public SetNVPairCommand[] getPropertyValues(String name, String type) throws NotConnectedException { >+ /* Determine if we have a connection */ >+ if (_connection == null) { >+ throw new NotConnectedException(); >+ } >+ >+ /* Request the process list from the client engine */ >+ ControlMessage message = new ControlMessage(); >+ GetPropertyListCommand command = new GetPropertyListCommand(); >+ command.setName(name); >+ command.setType(type); >+ message.appendCommand(command); >+ >+ synchronized (_propertyListLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _propertyListLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ return null; >+ } >+ } >+ >+ return props; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * Waits for a particular process to be present or the timeout value to be reached; after the process list returns (the internal process list in this node instance is updated) the process is retrieved via the get process method. The timeout value is approximate since there is some time needed to execute the various operations within the loop and each wait is done timeout divided by 2000 times. For example, a 60000 (60 second) timeout would cause the loop to execute 30 times and wait for 2 seconds at the end of each process list query. >+ * >+ * The listProcesses(...) method default wait time itself is up to 7 seconds to receive the process list. >+ * >+ */ >+ public synchronized Process waitForProcess(String processIdentity, int timeout) throws NotConnectedException, InactiveProcessException { >+ >+ // Change this from a polling model into a notify model >+ try { >+ for (int i = 0, j = timeout / 2000; i < j; i++) { >+ Enumeration processes = this.fastListProcesses(); >+ if (processes != null) { >+ for (; processes.hasMoreElements();) { >+ Process process = (Process) processes.nextElement(); >+ if (process.getProcessId().equals(processIdentity)) { >+ return process; >+ } >+ } >+ } >+ this.wait(2000); >+ } >+ } catch (InterruptedException e) { >+ // Do not need to handle this >+ } >+ >+ return null; // no process was found in the allowed time >+ } >+ >+ /** >+ * List the processes running in the node >+ * >+ * This method has side effects of setting the _processList member variable and populating the agents within each process in _processList Unlike the listProcesses() method, it does *not* retrieve the details for each agent. >+ */ >+ public Enumeration fastListProcesses() throws NotConnectedException { >+ ControlMessage message; >+ >+ if (_connection == null) { >+ throw new NotConnectedException(); >+ } else { >+ _connection.addConnectionListener(_connectionListener); // to avoid >+ // deadlock >+ >+ // Query the process list >+ message = new ControlMessage(); >+ QueryProcessListCommand qplCommand = new QueryProcessListCommand(); >+ message.appendCommand(qplCommand); >+ synchronized (_processListLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _processListLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ return null; >+ } >+ } >+ >+ // Populate the process with all agents >+ Enumeration ePIDs = _processList.keys(); >+ while (ePIDs.hasMoreElements()) { >+ Long pid = (Long) (ePIDs.nextElement()); >+ >+ // Query the agent list >+ message = new ControlMessage(); >+ QueryAgentListCommand qalCommand = new QueryAgentListCommand(); >+ qalCommand.setProcessId(pid.longValue()); >+ message.appendCommand(qalCommand); >+ synchronized (_agentListLock) { >+ try { >+ _connection.sendMessage(message, _commandHandler); >+ _agentListLock.wait(DEFAULT_TIMEOUT); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ return null; >+ } >+ } >+ } >+ >+ } >+ >+ return _processList.elements(); >+ } >+ >+ public void removeProcess(long pid) { >+ if (_processList.containsKey(new Long(pid))) { >+ _processList.remove(new Long(pid)); >+ } >+ } >+ >+ /** >+ * Handler for default context (0) >+ */ >+ public void incommingCommand(Node node, CommandElement command) { >+ _commandHandler.incommingCommand(node, command); >+ } >+ >+ private boolean isLocal() { >+ boolean isLocal = false; >+ >+ try { >+ InetAddress localAddr = InetAddress.getLocalHost(); >+ for (int i = 0; i < _addr.length; i++) { >+ if (localAddr.equals(_addr[i])) { >+ isLocal = true; >+ } >+ } >+ } catch (UnknownHostException e) { >+ } >+ >+ return isLocal; >+ } >+ >+ public boolean authenticateUser() { >+ if (_user != null) { >+ synchronized (_authenticationLock) { >+ try { >+ _user.login(_connection, _commandHandler); >+ _authenticationLock.wait(_authenticationTimeout); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ >+ return _isAuthenticated; >+ } >+ >+ public boolean isUserAuthenticated() { >+ return _isAuthenticated; >+ } >+ >+ class InnerConnectionListener implements ConnectionListener { >+ // If connection is lost, release all object locks >+ public void connectionClosed(Connection connection) { >+ synchronized (_processListLock) { >+ _processListLock.notifyAll(); >+ } >+ synchronized (_propertyListLock) { >+ _propertyListLock.notifyAll(); >+ } >+ } >+ } >+ >+ class InnerCommandHandler implements CommandHandler { >+ public void incommingCommand(Node node, CommandElement command) { >+ int tag = (int) command.getTag(); >+ switch (tag) { >+ case (int) Constants.RA_AUTHENTICATION_SUCCESSFUL: >+ _isAuthenticated = true; >+ synchronized (_authenticationLock) { >+ _authenticationLock.notifyAll(); >+ } >+ break; >+ case (int) Constants.RA_AUTHENTICATION_FAILED: >+ _isAuthenticated = false; >+ synchronized (_authenticationLock) { >+ _authenticationLock.notifyAll(); >+ } >+ break; >+ case (int) Constants.RA_PROCESS_LIST: { >+ RegisteredProcessListCommand rplCmd = (RegisteredProcessListCommand) command; >+ long[] pids = rplCmd.getProcessList(); >+ >+ // _processList.clear(); // Dangerous!!! Will remove all agents information within the process >+ // Clear the process list if there is no process registered >+ if ((pids == null) || (pids.length == 0)) { >+ _processList.clear(); >+ } else { >+ // Compare the returned process list and remove any terminated process >+ Enumeration e_tmp = _processList.keys(); >+ while (e_tmp.hasMoreElements()) { >+ Long pidstr_tmp = (Long) e_tmp.nextElement(); >+ Process p_tmp = (Process) _processList.get(pidstr_tmp); >+ try { >+ long pid_tmp = Long.parseLong(p_tmp.getProcessId()); >+ boolean exist = false; >+ // Check if the process is still in the returned process list >+ for (int i = 0; i < pids.length; i++) { >+ if (pids[i] == pid_tmp) { >+ exist = true; >+ } >+ } >+ if (!exist) { >+ _processList.remove(pidstr_tmp); >+ } >+ } catch (Exception e) { >+ } >+ } >+ >+ // Populate the process list >+ for (int i = 0; i < pids.length; i++) { >+ if (!_processList.containsKey(new Long(pids[i]))) { // Only >+ // create >+ // new >+ // process >+ // if >+ // not >+ // already >+ // exist >+ Process p = ProcessFactory.createProcess(node, pids[i]); >+ p.setActive(true); >+ _processList.put(new Long(pids[i]), p); >+ } >+ } >+ } >+ >+ synchronized (_processListLock) { >+ _processListLock.notifyAll(); >+ } >+ break; >+ } >+ case (int) Constants.RA_AGENT_LIST: { >+ ActiveAgentListCommand aalCmd = (ActiveAgentListCommand) (command); >+ >+ String[] agentNames = aalCmd.getAgents(); >+ String processName = aalCmd.getProcessName(); >+ long processId = aalCmd.getProcessId(); >+ >+ Process p = (Process) _processList.get(new Long(processId)); >+ p.setName(processName); >+ >+ if (agentNames != null) { >+ for (int i = 0; i < agentNames.length; i++) { >+ Agent newAgent = AgentFactory.createAgent(p, agentNames[i]); >+ newAgent.setActive(true); >+ } >+ } >+ >+ synchronized (_agentListLock) { >+ _agentListLock.notifyAll(); >+ } >+ break; >+ } >+ case (int) Constants.RA_AGENT_DETAILS: { >+ AgentDetailsCommand adCmd = (AgentDetailsCommand) command; >+ >+ long processId = adCmd.getProcessId(); >+ String processUUID = adCmd.getProcessUUID(); >+ String agentName = adCmd.getAgentName(); >+ String agentType = adCmd.getAgentType(); >+ String agentUUID = adCmd.getAgentUUID(); >+ >+ Process p = (Process) _processList.get(new Long(processId)); >+ >+ if (p != null) { >+ p.setUUID(processUUID); >+ Agent ag = p.getAgent(agentName); >+ if (ag != null) { >+ ag.setType(agentType); >+ ag.setUUID(agentUUID); >+ ag.addAgentListener((ProcessImpl) p); >+ } >+ } >+ >+ synchronized (_agentDetailsLock) { >+ _agentDetailsLock.notifyAll(); >+ } >+ break; >+ } >+ case (int) Constants.RA_PROCESS_LAUNCHED: >+ case (int) Constants.RA_PROCESS_EXITED: >+ case (int) Constants.RA_AGENT_ACTIVE: >+ case (int) Constants.RA_AGENT_INACTIVE: >+ case (int) Constants.RA_ERROR_STRING: >+ case (int) Constants.RA_CONSOLE_INFO: >+ case (int) Constants.RA_CUSTOM_COMMAND: >+ case (int) Constants.RA_BINARY_CUSTOM_COMMAND: >+ case (int) Constants.RA_SET_NAME_VALUE_PAIR: { >+ SimpleProcessCommand cmd = (SimpleProcessCommand) command; >+ long pid = cmd.getProcessId(); >+ >+ Process p = (Process) _processList.get(new Long(pid)); >+ if ((p != null) && (p instanceof ProcessImpl)) { >+ ((ProcessImpl) p).handleCommand(command); >+ } >+ >+ // Remote process if exited >+ if (tag == Constants.RA_PROCESS_EXITED) { >+ _processList.remove(new Long(pid)); >+ } >+ >+ break; >+ } >+ case (int) Constants.RA_PROPERTY_LIST: { >+ PropertyListCommand qs = (PropertyListCommand) command; >+ props = qs.getPropertyListValues(); >+ synchronized (_propertyListLock) { >+ _propertyListLock.notify(); >+ } >+ break; >+ } >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR: >+ case (int) Constants.RA_CONTROLLER_REQUEST_MONITOR_PORT: { >+ MonitorPeerRequestCommand cmd = (MonitorPeerRequestCommand) command; >+ long pid = cmd.getProcessId(); >+ >+ Process p = (Process) _processList.get(new Long(pid)); >+ if (p != null) { >+ try { >+ ((ProcessImpl) p).handleCommand(command); >+ } catch (ClassCastException e) { >+ // TODO: Error casting Process >+ } >+ } >+ break; >+ } >+ default: { >+ } >+ } >+ } >+ } >+ >+ /** >+ * Proess Listener >+ * >+ * @author samwai >+ * >+ */ >+ class InnerProcessListener implements ProcessListener { >+ public synchronized void processLaunched(Process process) { >+ try { >+ Long key = new Long(process.getProcessId()); >+ if (!_processList.containsKey(key)) { >+ _processList.put(key, process); >+ } >+ } catch (InactiveProcessException e) { >+ /* We can ignore this */ >+ } >+ } >+ >+ public synchronized void processExited(Process process) { >+ try { >+ Long key = new Long(process.getProcessId()); >+ _processList.remove(key); >+ } catch (InactiveProcessException e) { >+ /* We can ignore this */ >+ } >+ } >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/DetailedProcessCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/DetailedProcessCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/DetailedProcessCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/DetailedProcessCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DetailedProcessCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+/** >+ * Insert the type's description here. Creation date: (11/29/00 11:56:45 AM) >+ * >+ * @author: >+ */ >+public class DetailedProcessCommand extends SimpleProcessCommand { >+ >+ protected RAString _processUUID = new RAString(""); >+ >+ /** >+ * DetailedProcessCommand constructor comment. >+ */ >+ public DetailedProcessCommand() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/29/00 11:57:19 >+ * AM) >+ * >+ * @return java.lang.String >+ */ >+ public String getProcessUUID() { >+ if (_processUUID != null) { >+ return _processUUID.getData(); >+ } >+ return null; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ return super.getSize() + _processUUID.getSize(); >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _processUUID); >+ return current; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _processUUID); >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/SimpleProcessCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/SimpleProcessCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/SimpleProcessCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/SimpleProcessCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SimpleProcessCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public abstract class SimpleProcessCommand extends CommandElement implements Constants { >+ private long _processId; >+ >+ /** >+ * SimpleProcessCommand constructor comment. >+ */ >+ public SimpleProcessCommand() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 10:32:18 PM) >+ * >+ * @return long >+ */ >+ public long getProcessId() { >+ return _processId; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; >+ >+ return size; >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ _processId = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ return current; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (9/11/00 10:32:18 PM) >+ * >+ * @param new_pid >+ * long >+ */ >+ public void setProcessId(long pid) { >+ _processId = pid; >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _processId); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/Options.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/Options.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/Options.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/Options.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Options.java,v 1.6 2006/10/30 18:25:49 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public interface Options { >+ >+ /* Option Strings */ >+ public final static String OPTION_MONITOR_MODE = "MONITOR_MODE"; >+ public final static String OPTION_CLASS_LOAD_DETAILS = "CLASS_LOAD_DETAILS"; >+ public final static String OPTION_COLLATION_VALUES = "COLLATION_VALUES"; >+ public final static String OPTION_CONTEXT_FLOW = "CONTEXT_FLOW"; >+ public final static String OPTION_EXCEPTION_TRACING = "EXCEPTION_TRACING"; >+ public final static String OPTION_FILTERS = "FILTERS"; >+ public final static String OPTION_GC = "GC"; >+ public final static String OPTION_ID_STYLE = "ID_STYLE"; >+ public final static String OPTION_METHOD_COUNTS = "METHOD_COUNTS"; >+ public final static String OPTION_OBJ_ALLOC_IS_ARRAY = "OBJ_ALLOC_IS_ARRAY"; >+ public final static String OPTION_OPTIONS = "OPTIONS"; >+ public final static String OPTION_TICKET = "TICKET"; >+ public final static String OPTION_TIMESTAMPS = "TIMESTAMPS"; >+ public final static String OPTION_TRACE_IDREFS = "TRACE_IDREFS"; >+ public final static String OPTION_UNREFERENCED_SYMBOLS = "UNREFERENCED_SYMBOLS"; >+ public final static String OPTION_STACK_INFORMATION = "STACK_INFORMATION"; >+ public final static String OPTION_OBJ_REF_MODE = "OBJ_REF_MODE"; >+ /* V5 additions */ >+ public final static String OPTION_TRACE_MODE = "TRACE_MODE"; >+ public final static String OPTION_TRACE_START_MODE = "TRACE_START_MODE"; >+ public final static String OPTION_BURST_MODE = "BURST_MODE"; >+ public final static String OPTION_BOUNDARY_DEPTH = "BOUNDARY_DEPTH"; >+ public static final String OPTION_BURST_INVOCATIONS = "BURST_INVOCATIONS"; >+ public static final String OPTION_BURST_SECONDS = "BURST_SECONDS"; >+ public static final String OPTION_ALLOCATION_INFORMATION = "ALLOCATION_INFORMATION"; >+ >+ public static final String OPTION_COMPRESS = "COMPRESS"; >+ >+ public final static String OPTION_CPU_TIME = "CPU_TIME"; >+ /* Option Values */ >+ public static final String OPTION_VALUE_FULL = "full"; >+ public static final String OPTION_VALUE_ALL = "all"; >+ public static final String OPTION_VALUE_TRUE = "true"; >+ public static final String OPTION_VALUE_FALSE = "false"; >+ public static final String OPTION_VALUE_STATIC = "static"; >+ public static final String OPTION_VALUE_RELOCATABLE = "relocatable"; >+ public static final String OPTION_VALUE_STATICANDRELOCATABLE = "staticAndRelocatable"; >+ public static final String OPTION_VALUE_DEFAULT = "default"; >+ public static final String OPTION_VALUE_NONE = "none"; >+ public static final String OPTION_VALUE_DELETES = "deletes"; >+ public static final String OPTION_VALUE_DELETESANDMOVES = "deletesAndMoves"; >+ public static final String OPTION_VALUE_NORMAL = "normal"; >+ public static final String OPTION_VALUE_BOUNDARY = "boundary"; >+ public static final String OPTION_VALUE_CONTIGUOUS = "contiguous"; >+ public static final String OPTION_VALUE_BOUNDARYANDCONTIGUOUS = "boundaryAndContiguous"; >+ public static final String OPTION_VALUE_RESPECT_FILTER = "respectFilter"; >+ public static final String OPTION_VALUE_FILTER_OWNER = "filterOwner"; >+ public static final String OPTION_VALUE_IGNORE_FILTER = "ignoreFilter"; >+ /* V5 Additions */ >+ public final static String OPTION_VALUE_NOOBJECTCORRELATION = "noObjectCorrelation"; >+ public static final String OPTION_VALUE_FILTER = "filter"; >+ public static final String OPTION_VALUE_TRIGGERSINGLETHREADED = "triggerSingleThreaded"; >+ public static final String OPTION_VALUE_TRIGGERMULTITHREADED = "triggerMultiThreaded"; >+ public static final String OPTION_VALUE_INVOCATIONS = "invocations"; >+ public static final String OPTION_VALUE_SECONDS = "seconds"; >+ public static final String OPTION_VALUE_SECONDSANDINVOCATIONS = "secondsAndInvocations"; >+ >+ public static final String OPTION_VALUE_AGGREGATE = "aggregate"; >+ >+ /* >+ * This option must be in place if the user has selected execution flow without instance level information. >+ */ >+ public final static String[][] OPTIONS_EXECUTION_FLOW = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_STACK_INFORMATION, OPTION_VALUE_NORMAL }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ /* >+ * This option must be in place if the user has selected execution flow with instance level information. >+ */ >+ public final static String[][] OPTIONS_EXECUTION_FLOW_INSTANCES = { { OPTION_TRACE_MODE, OPTION_VALUE_FULL }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_DEFAULT }, { OPTION_STACK_INFORMATION, OPTION_VALUE_NORMAL }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ /* >+ * This option must be used if the user has selected execution flow and some boundary information, but no instance level information. >+ */ >+ public final static String[][] OPTIONS_EXECUTION_FLOW_BOUNDARY = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_STACK_INFORMATION, OPTION_VALUE_BOUNDARY }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ /* >+ * This option must be used if the user has selected execution flow and some boundary information, as well as instance level information. >+ */ >+ public final static String[][] OPTIONS_EXECUTION_FLOW_BOUNDARY_INSTANCES = { { OPTION_TRACE_MODE, OPTION_VALUE_FULL }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_DEFAULT }, { OPTION_STACK_INFORMATION, OPTION_VALUE_BOUNDARY }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ /* >+ * This option must be in place if the user has selected that they do not want any execution behaviour at all. >+ */ >+ public final static String[][] OPTIONS_EXECUTION_FLOW_NONE = { { OPTION_STACK_INFORMATION, OPTION_VALUE_NONE }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ /* This option must be in place if the user has selected to collect cpu time events */ >+ public final static String[][] OPTIONS_COLLECT_CPU_TIME = { { OPTION_CPU_TIME, OPTION_VALUE_TRUE }, }; >+ >+ /* >+ * This option must be in place if the user does not want object correlation information. >+ */ >+ public final static String[][] OPTIONS_NO_INSTANCE_INFORMATION = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_NONE } }; >+ >+ public final static String[][] OPTIONS_ANALYZE_HEAP = { { OPTION_TRACE_MODE, OPTION_VALUE_FULL }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_DEFAULT }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+ >+ public final static String[][] OPTIONS_ANALYZE_HEAP_NONE = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_NONE } }; >+ >+ /* >+ * This option must be in place if the user has selected Method Coverage but not EXECUTION_FLOW >+ */ >+ public final static String[][] OPTIONS_COVERAGE_NO_FLOW = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_STACK_INFORMATION, OPTION_VALUE_NORMAL }, { OPTION_METHOD_COUNTS, OPTION_VALUE_TRUE }, { OPTION_UNREFERENCED_SYMBOLS, OPTION_VALUE_TRUE } }; >+ >+ /* >+ * This option must be in place if the user has selected method coverage. >+ */ >+ public final static String[][] OPTIONS_COVERAGE = { { OPTION_TRACE_MODE, OPTION_VALUE_NOOBJECTCORRELATION }, { OPTION_METHOD_COUNTS, OPTION_VALUE_TRUE }, { OPTION_UNREFERENCED_SYMBOLS, OPTION_VALUE_TRUE } }; >+ >+ /* This option must be in place if the user has selected to observe threading events */ >+ >+ public final static String[][] OPTIONS_THREAD_EVENTS = { { OPTION_MONITOR_MODE, OPTION_VALUE_ALL } }; >+ >+ /* >+ * These are the default options, when nothing is selected. Nothing should be collected. These defaults are overridden once the options are set with values of higher precedence. >+ */ >+ public final static String[][] OPTIONS_DEFAULT = { { OPTION_TRACE_MODE, OPTION_VALUE_NONE }, { OPTION_ALLOCATION_INFORMATION, OPTION_VALUE_NONE }, { OPTION_STACK_INFORMATION, OPTION_VALUE_NONE }, { OPTION_TICKET, OPTION_VALUE_TRUE } }; >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/PeerUnreachableCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/PeerUnreachableCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/PeerUnreachableCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/PeerUnreachableCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: PeerUnreachableCommand.java,v 1.1 2006/03/06 19:49:40 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class PeerUnreachableCommand extends MonitorPeerRequestCommand { >+ >+ public PeerUnreachableCommand() { >+ super(); >+ _tag = RA_PEER_UNREACHABLE; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/security/User.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/User.java >diff -N src-local-public/org/eclipse/hyades/execution/security/User.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/User.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: User.java,v 1.5 2006/03/20 14:07:51 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import java.io.IOException; >+import java.security.Principal; >+ >+import org.eclipse.hyades.execution.core.util.Noop; >+import org.eclipse.hyades.execution.local.common.AuthenticateCommand; >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.local.control.Application; >+import org.eclipse.hyades.execution.local.control.CommandHandler; >+import org.eclipse.hyades.execution.local.control.Connection; >+import org.eclipse.hyades.execution.local.control.Node; >+ >+public class User implements Principal, CommandHandler { >+ >+ private String _name; >+ private String _password; >+ private Application _app; >+ private String _alias; >+ private boolean _isPasswordEncrypted; >+ >+ { >+ Noop.sink(this._alias, this._isPasswordEncrypted); >+ } >+ >+ public static final boolean ENABLE_PASSWORD_ENCRYPTION = false; >+ >+ public User(Application app, String name, String password) { >+ _app = app; >+ _name = name; >+ setPassword(password); >+ } >+ >+ /** >+ * @see java.security.Principal#getName() >+ */ >+ public String getName() { >+ return _name; >+ } >+ >+ public void setPassword(String password) { >+ /* >+ * Try and store the passowrd in memory encrypted. If we fail to encrypt >+ * the password we will store it as is. >+ */ >+ try { >+ if (ENABLE_PASSWORD_ENCRYPTION) { >+ // _password=com.ibm.ISecurityUtilityImpl.PasswordUtil.encode(password); >+ _isPasswordEncrypted = true; >+ } else { >+ throw new RuntimeException(); >+ } >+ } catch (Exception e) { >+ _password = password; >+ _isPasswordEncrypted = false; >+ } >+ >+ } >+ >+ public Application getApplication() { >+ return _app; >+ } >+ >+ public void login(Connection connection) throws IOException { >+ login(connection, this); >+ } >+ >+ public void login(Connection connection, CommandHandler handler) throws IOException { >+ >+ ControlMessage message = new ControlMessage(); >+ AuthenticateCommand command = null; >+ ; >+ >+ String decryptedPassword = null; >+ try { >+ >+ if (ENABLE_PASSWORD_ENCRYPTION) { >+ // decryptedPassword=com.ibm.ISecurityUtilityImpl.PasswordUtil.decode(_password); >+ } else { >+ throw new RuntimeException(); >+ } >+ } catch (Exception e) { >+ decryptedPassword = _password; >+ } >+ command = new AuthenticateCommand(_name, decryptedPassword); >+ message.appendCommand(command); >+ connection.sendMessage(message, handler); >+ } >+ >+ public void incommingCommand(Node node, CommandElement command) { >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_AUTHENTICATION_SUCCESSFUL: >+ break; >+ case (int) Constants.RA_AUTHENTICATION_FAILED: >+ break; >+ } >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Application.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Application.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Application.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Application.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Application.java,v 1.2 2005/02/25 22:17:10 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.security.Principal; >+ >+public interface Application extends Principal { >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/RABinaryArray.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/RABinaryArray.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/RABinaryArray.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/RABinaryArray.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: RABinaryArray.java,v 1.3 2005/04/05 15:48:58 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class RABinaryArray implements Constants { >+ >+ protected byte[] _data; >+ protected int _padding = 0; >+ >+ public RABinaryArray() { >+ super(); >+ } >+ >+ public RABinaryArray(byte[] data) { >+ if (data != null) { >+ _data = data; >+ calculatePadding(); >+ } else { >+ _padding = 0; >+ } >+ } >+ >+ private void calculatePadding() { >+ _padding = 4 - _data.length % 4; >+ if (_padding == 4) { >+ _padding = 0; >+ } >+ } >+ >+ public byte[] getData() { >+ return _data; >+ } >+ >+ public int getPadding() { >+ return _padding; >+ } >+ >+ public int getSize() { >+ return sizeofLong + _data.length + _padding; >+ } >+ >+ public long length() { >+ if (_data != null) >+ return _data.length; >+ >+ return 0; >+ } >+ >+ public void setData(byte[] data) { >+ _data = data; >+ calculatePadding(); >+ } >+ >+ public void setData(byte[] data, int offset, int length) { >+ if (data != null) { >+ _data = new byte[length]; >+ System.arraycopy(data, offset, _data, 0, length); >+ calculatePadding(); >+ } >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/security/SecureConnectionRequiredException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/security/SecureConnectionRequiredException.java >diff -N src-local-public/org/eclipse/hyades/execution/security/SecureConnectionRequiredException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/security/SecureConnectionRequiredException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SecureConnectionRequiredException.java,v 1.4 2005/09/13 16:46:21 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.security; >+ >+import org.eclipse.hyades.execution.local.common.ServerSecurityInfoCommand; >+import org.eclipse.hyades.execution.local.control.AgentControllerUnavailableException; >+ >+public class SecureConnectionRequiredException extends AgentControllerUnavailableException { >+ >+ private static final long serialVersionUID = 3977858458274181938L; >+ ServerSecurityInfoCommand _details; >+ >+ public SecureConnectionRequiredException(ServerSecurityInfoCommand command) { >+ _details = command; >+ } >+ >+ public boolean isPasswordProtected() { >+ return _details.isPasswordProtected(); >+ } >+ >+ public boolean isClientAuthenticationRequired() { >+ return _details.isClientAuthenticationRequired(); >+ } >+ >+ public long getSecurePort() { >+ return _details.getSecurePort(); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/RAString.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/RAString.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/RAString.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/RAString.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,111 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: RAString.java,v 1.4 2005/11/04 19:06:30 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class RAString implements Constants { >+ protected String _data = ""; >+ protected int _padding = 0; >+ >+ /** >+ * RAString constructor comment. >+ */ >+ public RAString() { >+ super(); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 8:07:25 PM) >+ * >+ * @param data >+ * java.lang.String >+ */ >+ public RAString(String data) { >+ setData(data); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 10:18:58 PM) >+ */ >+ private void calculatePadding() { >+ try { >+ _padding = 4 - _data.getBytes("UTF-8").length % 4; >+ if (_padding == 4) { >+ _padding = 0; >+ } >+ } catch (Exception e) { >+ _padding = 4 - _data.length() % 4; >+ if (_padding == 4) { >+ _padding = 0; >+ } >+ } >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 8:08:17 PM) >+ * >+ * @return java.lang.String >+ */ >+ public String getData() { >+ return _data; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 8:08:30 PM) >+ * >+ * @return int >+ */ >+ public int getPadding() { >+ return _padding; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 8:12:24 PM) >+ * >+ * @return long >+ */ >+ public int getSize() { >+ try { >+ return sizeofLong + _data.getBytes("UTF-8").length + _padding; >+ } catch (Throwable e) { >+ return sizeofLong + _data.length() + _padding; >+ } >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (10/31/00 8:09:17 PM) >+ * >+ * @return long >+ */ >+ public long length() { >+ if (_data != null) >+ return _data.length(); >+ >+ return 0; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (11/2/00 5:17:34 PM) >+ * >+ * @param data >+ * java.lang.String >+ */ >+ public void setData(String data) { >+ if (data != null) { >+ _data = data; >+ calculatePadding(); >+ } else { >+ _data = ""; >+ _padding = 0; >+ } >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/DataServerListener.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/DataServerListener.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/DataServerListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/DataServerListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DataServerListener.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+/** >+ * This interface is used in conjunction with the TCPDataServer to notify >+ * implementors when the TCPDataProcessor has completed doing all of its work >+ * and the processor is exiting. >+ */ >+public interface DataServerListener extends DataProcessor { >+ >+ void dataServerExited(); >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/GetPropertyListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/GetPropertyListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/GetPropertyListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/GetPropertyListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: GetPropertyListCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class GetPropertyListCommand extends CommandElement implements Constants { >+ private RAString name = null; >+ private RAString type = null; >+ private RAString agentUUID = new RAString(""); >+ >+ public GetPropertyListCommand() { >+ super(); >+ _tag = RA_GET_PROPERTY_LIST; >+ } >+ >+ public void setName(String str) { >+ name = new RAString(str); >+ } >+ >+ public RAString getName() { >+ return name; >+ } >+ >+ public void setType(String str) { >+ type = new RAString(str); >+ } >+ >+ public RAString getType() { >+ return type; >+ } >+ >+ public void setAgentUUID(String str) { >+ agentUUID = new RAString(str); >+ } >+ >+ public RAString getAgentUUID() { >+ return agentUUID; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ current = Message.readRAStringFromBuffer(buffer, current, name); >+ current = Message.readRAStringFromBuffer(buffer, current, type); >+ current = Message.readRAStringFromBuffer(buffer, current, agentUUID); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRAStringToBuffer(buffer, current, name); >+ current = Message.writeRAStringToBuffer(buffer, current, type); >+ current = Message.writeRAStringToBuffer(buffer, current, agentUUID); >+ >+ return current; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += name.getSize(); >+ size += type.getSize(); >+ size += agentUUID.getSize(); >+ >+ return size; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ResourceLocation.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ResourceLocation.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ResourceLocation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ResourceLocation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ResourceLocation.java,v 1.5 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ResourceLocation extends CommandElement implements Constants { >+ private long _port; >+ private RAString _jobKey = new RAString(""); >+ >+ public ResourceLocation() { >+ super(); >+ _tag = RA_RESOURCE_LOCATION; >+ } >+ >+ public int getPort() { >+ return (int) _port; >+ } >+ >+ public void setPort(int port) { >+ _port = port; >+ } >+ >+ public String getJobKey() { >+ return _jobKey.getData(); >+ } >+ >+ public void setJobKey(String key) { >+ _jobKey = new RAString(key); >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // port >+ size += _jobKey.getSize(); >+ >+ return size; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ _port = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ current = Message.readRAStringFromBuffer(buffer, current, _jobKey); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _port); >+ current = Message.writeRAStringToBuffer(buffer, current, _jobKey); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionImpl.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ConnectionImpl.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ConnectionImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ConnectionImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,556 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ConnectionImpl.java,v 1.10 2006/05/13 02:02:53 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InterruptedIOException; >+import java.io.OutputStream; >+import java.net.InetAddress; >+import java.net.Socket; >+import java.net.SocketException; >+import java.util.Enumeration; >+import java.util.Vector; >+ >+import org.eclipse.hyades.execution.local.common.CommandElement; >+import org.eclipse.hyades.execution.local.common.Constants; >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.local.common.Message; >+import org.eclipse.hyades.execution.local.common.ServerSecurityInfoCommand; >+import org.eclipse.hyades.execution.security.AuthenticationListener; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+ >+public class ConnectionImpl implements Connection { >+ >+ protected Socket _socket; >+ >+ protected Node _node; >+ >+ protected int _port; >+ >+ private static long _context = 1; >+ >+ private ContextMapper _contextMapper = null; >+ >+ private CommandHandler _cmdHandler = null; >+ >+ private boolean _isComplete = false; >+ >+ private final Vector _listeners = new Vector(); >+ >+ // private final Vector _authenticationlisteners = new Vector(); >+ >+ private final Object _connectionLock = new Object(); >+ >+ private static final Object contextLock = new Object(); >+ >+ private boolean _isInitialized = false; >+ >+ private SecureConnectionRequiredException _connectionException = null; >+ >+ private int _connectionTimeout = 10000; // 10 sec >+ >+ public ConnectionImpl() { >+ super(); >+ } >+ >+ public void connect(Node node, int port) throws IOException, LoginFailedException, SecureConnectionRequiredException, UntrustedAgentControllerException { >+ _port = port; >+ int offset = 0; >+ InetAddress[] addrs = node.getAllInetAddresses(); >+ >+ do { >+ /* Connect to the remote machine */ >+ try { >+ _socket = new Socket(addrs[offset], port); >+ break; >+ } catch (IOException e) { >+ offset++; >+ if (offset == addrs.length) { >+ throw e; >+ } >+ } >+ } while (offset < addrs.length); >+ >+ _node = node; >+ this.init(); >+ } >+ >+ /* Init */ >+ protected void init() throws IOException, SecureConnectionRequiredException { >+ >+ /* Set the timeout on the socket reader to be 1 second */ >+ try { >+ _socket.setSoTimeout(1000); >+ _socket.setTcpNoDelay(true); >+ } catch (SocketException e) { >+ /* We can ignore this */ >+ } >+ >+ _connectionException = null; >+ _contextMapper = new ContextMapper(); >+ _cmdHandler = new CommandHandler() { >+ public void incommingCommand(Node node, CommandElement command) { >+ long contextId = command.getContext(); >+ >+ /* Intercept authentication requests */ >+ switch ((int) command.getTag()) { >+ case (int) Constants.RA_SERVER_SECURITY_REQUIREMENTS: >+ _connectionException = new SecureConnectionRequiredException((ServerSecurityInfoCommand) command); >+ synchronized(_connectionLock) { >+ _connectionLock.notifyAll(); >+ } >+ disconnect(); >+ break; >+ default: >+ synchronized(_connectionLock) { >+ _connectionLock.notifyAll(); >+ } >+ >+ /* >+ * Find the command handler associated with this contextId >+ * and forward the message appropriately. >+ */ >+ CommandHandler ch = _contextMapper.getHandler(contextId); >+ if (ch != null) { >+ ch.incommingCommand(_node, command); >+ } else { >+ _node.incommingCommand(_node, command); >+ } >+ } >+ } >+ }; >+ >+ /* >+ * RKD: With the V5 Agent Controller it first accepts the socket >+ * connection and then determines is the connection is allowed. If the >+ * connection is not allowed the the connection is cut. We need to first >+ * connect and then determine if we have been cut off. The connection >+ * has already occurred above us in the stack. We then will wait until >+ * either a read timeout has occured on the reader thread or the >+ * connection gets cut by the other side. >+ */ >+ >+ SocketReaderThread reader = new SocketReaderThread(); >+ if (_node.getUser() == null) { >+ reader.setName(_node.getName() + "_connection"); >+ } else { >+ reader.setName(_node.getName() + "_" + _node.getUser().getName() + "_connection"); >+ } >+ reader.setDaemon(true); >+ reader.start(); >+ >+ _isInitialized = true; >+ >+ /* >+ * If this connection has a pending exception because the server is >+ * secure we need to throw the exception so that the caller can >+ * create a new connection with the proper security settings. >+ */ >+ synchronized (_connectionLock) { >+ try { >+ _connectionLock.wait(_connectionTimeout); >+ } catch (InterruptedException e) { >+ e.printStackTrace(); >+ } >+ >+ if (_connectionException != null) { >+ throw _connectionException; >+ } >+ } >+ } >+ >+ public void sendMessage(ControlMessage msg, CommandHandler handler) throws IOException { >+ >+ int count = msg.getSize(); >+ byte[] buffer = new byte[count]; >+ >+ int commandCount = msg.getCommandCount(); >+ >+ /* >+ * Need to store the context for rerouting on return, lock is acquired >+ * so context static variable can be incremented safely, synchronized >+ * surrounds loop instead of inside loop to minimize acquisition of >+ * locks within loop. >+ * >+ * The part of the loop that did not deal with incrementing and storing >+ * the context has been extracted out into another loop as to minimize >+ * time of lock. >+ */ >+ synchronized (ConnectionImpl.contextLock) { >+ for (int i = 0; i < commandCount; i++) { >+ msg.getCommand(i).setContext(ConnectionImpl._context++); >+ } >+ } >+ >+ /* >+ * The command count loop is repeated outside of the synchronized block >+ * to minimize duration of the context lock. >+ */ >+ for (int i = 0; i < commandCount; i++) { >+ this._contextMapper.addContext(msg.getCommand(i).getContext(), handler); >+ } >+ >+ msg.writeToBuffer(buffer, 0); >+ >+ OutputStream stream = _socket.getOutputStream(); >+ stream.write(buffer); >+ stream.flush(); >+ >+ } >+ >+ public void disconnect() { >+ synchronized (_connectionLock) { >+ if (!_isComplete) { >+ _isComplete = true; >+ _connectionLock.notifyAll(); >+ try { >+ _socket.close(); >+ } catch (IOException e) { >+ /* We can ignore this */ >+ } >+ >+ /* >+ * If this is a nodeimpl clear the keystore spec so it tries an >+ * insecure connect next time >+ * >+ * NOTE: Commented out since this might be overwriting the security >+ * parameter when the secured control channel and secured file >+ * server both access the same NodeImpl. This is when the insecured >+ * connection is disconnecting. Please see TPTP bug 136426. >+ */ >+// if (_node instanceof NodeImpl) { >+// ((NodeImpl) _node).setSecurityParameters(null); // Bug 136426 >+// } >+ >+ /* Inform each of the listeners that the connection is closed. */ >+ synchronized (_listeners) { >+ Enumeration e = _listeners.elements(); >+ while (e.hasMoreElements()) { >+ ConnectionListener listener = (ConnectionListener) e.nextElement(); >+ listener.connectionClosed(this); >+ } >+ } >+ } >+ } >+ } >+ >+ public Node getNode() { >+ return _node; >+ } >+ >+ public boolean isActive() { >+ if (_isInitialized) { >+ return !_isComplete; >+ } >+ return false; >+ } >+ >+ public int getPort() { >+ return _port; >+ } >+ >+ /** >+ * @see Connection#addConnectionListener(ConnectionListener) >+ */ >+ public void addConnectionListener(ConnectionListener listener) { >+ synchronized (_listeners) { >+ if (!_listeners.contains(listener)) { >+ _listeners.add(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Connection#removeConnectionListener(ConnectionListener) >+ */ >+ public void removeConnectionListener(ConnectionListener listener) { >+ synchronized (_listeners) { >+ if (_listeners.contains(listener)) { >+ _listeners.remove(listener); >+ } >+ } >+ } >+ >+ /** >+ * @see Connection#addAuthenticationListener(AuthenticationListener) >+ */ >+ public void addAuthenticationListener(AuthenticationListener listener) { >+ // synchronized(_authenticationlisteners) { >+ // if(!_authenticationlisteners.contains(listener)) { >+ // _authenticationlisteners.add(listener); >+ // } >+ // } >+ >+ } >+ >+ /** >+ * @see Connection#removeAuthenticationListener(AuthenticationListener) >+ */ >+ public void removeAuthenticationListener(AuthenticationListener listener) { >+ // synchronized(_authenticationlisteners) { >+ // if(_authenticationlisteners.contains(listener)) { >+ // _authenticationlisteners.remove(listener); >+ // } >+ // } >+ } >+ >+ protected int processControlMessage(byte[] buffer, int offset, int length) { >+ if (_cmdHandler != null) { >+ ControlMessage msg = new ControlMessage(); >+ int current = -1; >+ try { >+ current = msg.readFromBuffer(buffer, offset, length); >+ >+ /* If we read more bytes then were valid, return -1 */ >+ if (current > offset + length) { >+ return -1; >+ } >+ } catch (IndexOutOfBoundsException e) { /* >+ * 185463 changed to >+ * superclass because both >+ * String and Array >+ * IndexOutOfBoundsExceptions >+ * can be thrown >+ */ >+ /* >+ * We have reached the end of the buffer so we have an >+ * incomplete message, return -1 >+ */ >+ return -1; >+ } catch (Exception e) { >+ /* >+ * There was some other exception reading the message so we >+ * can't handle the message. return -1 to indicate an error >+ */ >+ return -1; /* 185463 */ >+ } >+ >+ /* If we have parsed the message successfully Then process it */ >+ if (current == msg.getLength() + offset) { >+ /* Valid pass on each command */ >+ int count = msg.getCommandCount(); >+ for (int i = 0; i < count; i++) { >+ _cmdHandler.incommingCommand(_node, msg.getCommand(i)); >+ } >+ } >+ >+ return current; >+ } >+ return -1; >+ } >+ >+ class SocketReaderThread extends Thread implements Constants { >+ >+ public void run() { >+ >+ /* Run forever */ >+ byte[] buffer = new byte[MAX_MESSAGE_LENGTH]; >+ int masterOffset = 0; >+ int msgOffset = 0; >+ boolean incompleteMsg; /* 185463 */ >+ int timeoutCount = 0; >+ >+ while (!_isComplete) { >+ incompleteMsg = false; /* 185463 */ >+ >+ try { >+ >+ /* >+ * Get the InputStream for this socket so we can read some >+ * data >+ */ >+ InputStream inStream = _socket.getInputStream(); >+ >+ // >>> Bug 128421 begins >+ // Workaround to avoid JVM inconsistency of implementation >+ // of InputStream.read() >+ // In some JSSE implementation the read(buf, off, 0) blocks >+ int bytesRead; >+ int len = buffer.length - masterOffset; >+ if (len == 0) { >+ bytesRead = 0; // Avoid reading from input stream if >+ // there is nothing to read >+ } else { >+ bytesRead = inStream.read(buffer, masterOffset, len); >+ } >+ // int bytesRead=inStream.read(buffer, masterOffset, >+ // buffer.length-masterOffset); >+ // <<< Bug 128421 ends >+ >+ if (bytesRead == -1) { >+ break; >+ } >+ >+ /* Is this a valid message type */ >+ Message incommingMessage = new Message(); >+ >+ while (msgOffset < (bytesRead + masterOffset)) { >+ int newOffset = 0; >+ /* >+ * First we try and read the message header information. >+ * It may be that we overrun our buffer or we overrun >+ * the number of bytes written. If either is the case, >+ * compress and re-read. >+ */ >+ try { >+ newOffset = incommingMessage.readFromBuffer(buffer, msgOffset); >+ >+ /* >+ * Did we overrun the bytes written? ie do we have >+ * an incomplete message header? bugzilla 113831 - >+ * also changed the test from > to >= because if it >+ * they are equal then the message length is missing >+ * from the header so the message is incomplete. >+ */ >+ if (newOffset >= (masterOffset + bytesRead)) { >+ /* >+ * Assumption is that we have processed other >+ * parts of the message so masterOffset > 0 >+ */ >+ /* >+ * Compress the buffer and read the socket to >+ * get the remainder of the message >+ */ >+ if (msgOffset > 0) { >+ masterOffset = masterOffset + bytesRead - msgOffset; >+ for (int i = 0; i < masterOffset; i++) { >+ buffer[i] = buffer[msgOffset + i]; >+ } >+ msgOffset = 0; >+ } >+ incompleteMsg = true; >+ >+ break; >+ /* 185463 end */ >+ } >+ } catch (IndexOutOfBoundsException e) { /* 185463 */ >+ /* >+ * We overran our buffer so we have an incomplete >+ * message. Compress the buffer and read the socket >+ * to get the remainder of the message Assumption is >+ * that we have processed other parts of the message >+ * so masterOffset > 0 >+ */ >+ if (msgOffset > 0) { >+ masterOffset = masterOffset + bytesRead - msgOffset; >+ for (int i = 0; i < masterOffset; i++) { >+ buffer[i] = buffer[msgOffset + i]; >+ } >+ msgOffset = 0; >+ } >+ incompleteMsg = true; >+ break; >+ } catch (Exception e) { >+ /* >+ * Don't know what happened here so let's ignore >+ * this message and get the next one >+ */ >+ /* Should log a message here */ >+ System.out.println(e.toString()); >+ break; >+ /* 185463 end */ >+ } >+ >+ /* >+ * We have the header information, now lets try and get >+ * the entire message. Once again the same error >+ * conditions can occur. >+ */ >+ if (incommingMessage.getType() != RA_ACKNOWLEDGEMENT_MESSAGE) { >+ newOffset = processControlMessage(buffer, msgOffset, bytesRead + masterOffset - msgOffset); >+ /* >+ * If there was an error processing the message or >+ * we overran the data read from the socket then we >+ * have an incomplete message so we have to go back >+ * and read the rest of the message from the socket >+ */ >+ if (newOffset == -1) { >+ /* >+ * If we processed some of the message Then move >+ * the remainder of the message to the beginning >+ * of the buffer so we have more room to read >+ * from the socket >+ */ >+ incompleteMsg = true; >+ if (msgOffset > 0) { >+ masterOffset = masterOffset + bytesRead - msgOffset; >+ for (int i = 0; i < masterOffset; i++) { >+ buffer[i] = buffer[msgOffset + i]; >+ } >+ msgOffset = 0; >+ } else { >+ // If buffer is completely filled up >+ if ((bytesRead == 0) && (masterOffset == buffer.length)) { >+ byte[] tmpbuffer = new byte[buffer.length * 2]; // double >+ // the >+ // buffer >+ // size >+ /* >+ * Copy necessary data over to new >+ * buffer >+ */ >+ System.arraycopy(buffer, 0, tmpbuffer, 0, buffer.length); >+ buffer = tmpbuffer; >+ } >+ masterOffset += bytesRead; >+ } >+ break; >+ /* 185463 end */ >+ } >+ >+ msgOffset = newOffset; >+ } >+ } /* end of inner while */ >+ >+ /* 185463 begin */ >+ if (!incompleteMsg) { >+ masterOffset = 0; >+ msgOffset = 0; >+ } >+ /* 185463 end */ >+ } catch (InterruptedIOException e) { >+ /* >+ * This happens as the read has timed out. Just continue as >+ * the socket is still valid. If we are still locked because >+ * we are unsure if the connection is good then we should >+ * make sure we allow it to continue. >+ */ >+ if (timeoutCount > 6 && !_isInitialized) { >+ synchronized (_connectionLock) { >+ _connectionLock.notifyAll(); >+ } >+ } >+ timeoutCount++; >+ >+ } catch (SocketException e) { >+ /* >+ * this is thrown when the RAC cuts our connection because >+ * we must support security or if the host has been denied >+ * access >+ */ >+ >+ break; >+ >+ } catch (IOException e) { >+ break; >+ } >+ } /* end of outer while */ >+ /* The server is now stopping */ >+ disconnect(); >+ } >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AttachToAgentCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AttachToAgentCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AttachToAgentCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AttachToAgentCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AttachToAgentCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AttachToAgentCommand extends SimpleAgentInfoCommand { >+ >+ /** >+ * AttachToVMCommand constructor comment. >+ */ >+ public AttachToAgentCommand() { >+ super(); >+ _tag = RA_ATTACH_TO_AGENT; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringLocalAgentCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringLocalAgentCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringLocalAgentCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/StartMonitoringLocalAgentCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: StartMonitoringLocalAgentCommand.java,v 1.2 2006/02/06 17:39:31 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class StartMonitoringLocalAgentCommand extends SimpleAgentInfoCommand { >+ private RAString _file = new RAString(); >+ >+ public StartMonitoringLocalAgentCommand() { >+ super(); >+ _tag = RA_START_MONITORING_AGENT_LOCAL; >+ } >+ >+ public String getFile() { >+ return _file.getData(); >+ } >+ >+ public void setFile(String file) { >+ _file = new RAString(file); >+ } >+ >+ public int getSize() { >+ return super.getSize() + _file.getSize(); >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _file); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ current = Message.writeRAStringToBuffer(buffer, current, _file); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ShutdownCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ShutdownCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ShutdownCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ShutdownCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ShutdownCommand.java,v 1.1 2006/05/03 19:36:54 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ShutdownCommand extends CommandElement { >+ >+ public ShutdownCommand() { >+ _tag = Constants.RA_SHUTDOWN; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/Console.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/Console.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/Console.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/Console.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,311 @@ >+/********************************************************************** >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Console.java,v 1.8 2006/10/30 18:25:49 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InterruptedIOException; >+import java.net.InetAddress; >+import java.net.ServerSocket; >+import java.net.Socket; >+import java.net.UnknownHostException; >+ >+import org.eclipse.hyades.execution.core.file.IFileManagerExtended; >+import org.eclipse.hyades.execution.local.control.Node; >+import org.eclipse.hyades.execution.local.file.FileManagerFactory; >+ >+public class Console extends Thread implements Constants { >+ >+ protected ServerSocket _sock; >+ >+ protected DataProcessor _processor; >+ >+ protected long _ip = 0; >+ >+ protected long _port = 0; >+ >+ protected Node _node; >+ >+ private boolean _started = false; >+ >+ private boolean _valid = true; >+ >+ private Socket _activeConnection; >+ >+ /** >+ * Console constructor comment. >+ */ >+ public Console() { >+ super(); >+ /* Don't block the VM from exiting */ >+ this.setName("Console"); /* 9707 */ >+ this.setDaemon(true); >+ } >+ >+ /** >+ * Construct a console that knows about the node that will try to >+ * communicate with it >+ */ >+ public Console(Node node) { >+ this(); >+ this._node = node; >+ } >+ >+ /** >+ * Console constructor comment. >+ * >+ * @param name >+ * java.lang.String >+ */ >+ public Console(String name) { >+ super(name); >+ /* Don't block the VM from exiting */ >+ this.setDaemon(true); >+ } >+ >+ /** >+ * Console constructor comment. >+ * >+ * @param group >+ * java.lang.ThreadGroup >+ * @param name >+ * java.lang.String >+ */ >+ public Console(ThreadGroup group, String name) { >+ super(group, name); >+ /* Don't block the VM from exiting */ >+ this.setDaemon(true); >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (2/19/01 2:44:15 PM) >+ * >+ * @return long >+ */ >+ public long getIP() throws ConsoleNotStartedException { >+ if (_ip == 0) { >+ throw new ConsoleNotStartedException(); >+ } >+ return _ip; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (2/19/01 2:43:59 PM) >+ * >+ * @return long >+ */ >+ public long getPort() throws ConsoleNotStartedException { >+ if (_port == 0) { >+ throw new ConsoleNotStartedException(); >+ } >+ return _port; >+ } >+ >+ /** >+ * Return the server socket used by the console thread >+ * >+ * @return java.net.ServerSocket >+ * @throws ConsoleNotStartedException >+ */ >+ public ServerSocket getServerSocket() throws ConsoleNotStartedException { >+ if (_sock == null) { >+ throw new ConsoleNotStartedException(); /* 9707 */ >+ } >+ >+ return _sock; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (2/19/01 2:43:25 PM) >+ */ >+ public void run() { >+ byte[] buffer = new byte[1024]; >+ short port = 0/* DATA_PORT_NUM_CLIENT */; >+ boolean started = false; >+ boolean complete; >+ >+ /* Start the server */ >+ while (!started) { >+ try { >+ started = true; >+ _sock = new ServerSocket(port, 1); >+ } catch (Exception e) { >+ port++; >+ started = false; >+ } >+ } >+ >+ /* Store the address information of this console */ >+ _port = _sock.getLocalPort(); >+ InetAddress localHost = null; >+ try { >+ localHost = InetAddress.getLocalHost(); >+ byte[] bytes = localHost.getAddress(); >+ _ip = (long) (bytes[3] << 24 & 0xff000000) | (long) (bytes[2] << 16 & 0x00ff0000) | (long) (bytes[1] << 8 & 0x0000ff00) | (long) (bytes[0] & 0x000000ff); >+ } catch (UnknownHostException e) { >+ /* Shouldn't happen as we are looking up the localhost */ >+ } >+ >+ /** >+ * If server cannot reach to client do not start console server, >+ * basically the launch process command will use 0 as IP and port which >+ * indicates no console traffic will be brought back to the client side >+ * (and therefore no chance for the firewall to block it since the >+ * server reach command is indicating this is what will happen if >+ * attempted) -- if server can indeed reach to client then proceed >+ * typically (using console server) >+ */ >+ boolean serverCanReach = false; >+ try { >+ org.eclipse.hyades.internal.execution.local.control.NodeImpl node; >+ node = new org.eclipse.hyades.internal.execution.local.control.NodeImpl(_node.getName(), _node.getAllInetAddresses()); >+ node.connect(_node.getConnection().getPort()); >+ >+ IFileManagerExtended fileManager = FileManagerFactory.getInstance().create(node.getConnection()); >+ serverCanReach = fileManager.determineServerReach(localHost.getHostAddress(), (int) this._port); >+ node.getConnection().disconnect(); >+ } catch (Exception e) { >+ e.printStackTrace(); >+ } >+ >+ /* Inform the start method we are up */ >+ synchronized (this) { >+ _started = true; >+ this.notify(); >+ } >+ >+ if (serverCanReach) { >+ >+ while (_valid) { >+ InputStream is = null; >+ _activeConnection = null; >+ try { >+ _activeConnection = _sock.accept(); >+ is = _activeConnection.getInputStream(); >+ _activeConnection.setSoTimeout(1000); >+ complete = false; >+ } catch (Exception e) { >+ /* The server socket is toast, return */ >+ return; >+ } >+ while (!complete) { >+ int length = 0; >+ try { >+ length = is.read(buffer); >+ } catch (InterruptedIOException e) { >+ /* Read timeout, don't want to wait too long */ >+ if (_processor != null) { >+ _processor.waitingForData(); >+ } >+ } catch (IOException e) { >+ try { >+ _activeConnection.close(); >+ } catch (IOException e1) { >+ } >+ complete = true; >+ } >+ >+ /* Is the connection closed? */ >+ if (length < 0) { >+ try { >+ _activeConnection.close(); >+ } catch (IOException e) { >+ } >+ complete = true; >+ } else if (length > 0) { >+ if (_processor != null) { >+ _processor.incommingData(buffer, length, _activeConnection.getInetAddress()); >+ } >+ } >+ >+ /* Have we been asked to stop. */ >+ if (!_valid) { >+ try { >+ _activeConnection.close(); >+ } catch (IOException e1) { >+ } >+ complete = true; >+ } >+ } >+ } >+ >+ } else { >+ >+ /* >+ * If server cannot reach back, close new server socket and reset ip >+ * and port to zero, these values will be attached to the launch >+ * process command, if they are zero then server will not attempt to >+ * connect to console started in this object >+ */ >+ this._ip = 0; >+ this._port = 0; >+ this.close(); >+ >+ } >+ >+ } >+ >+ public void setDataProcessor(DataProcessor processor) { >+ _processor = processor; >+ >+ } >+ >+ public DataProcessor getDataProcessor() { >+ return _processor; >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (2/19/01 5:39:25 PM) >+ */ >+ public void start() { >+ /* We need to wait until the server is fully up */ >+ synchronized (this) { >+ _valid = true; >+ super.start(); >+ do { >+ try { >+ this.wait(); >+ } catch (InterruptedException e) { >+ } >+ } while (!_started); >+ } >+ } >+ >+ /** >+ * Insert the method's description here. Creation date: (5/28/01 8:01:54 PM) >+ * >+ * @param data >+ * java.lang.String >+ */ >+ public void write(String data) { >+ if (_activeConnection != null) { >+ try { >+ _activeConnection.getOutputStream().write(data.getBytes("UTF-8")); // Bug >+ // 73074 >+ } catch (Exception e) { >+ } >+ } >+ } >+ >+ /* Closes this console */ >+ public void close() { >+ if (_sock != null) { >+ try { >+ _sock.close(); >+ } catch (IOException e) { >+ } >+ } >+ _valid = false; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/NotImplementedException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/NotImplementedException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/NotImplementedException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/NotImplementedException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: NotImplementedException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class NotImplementedException extends RuntimeException { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 8162168654381613705L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/BinaryCustomCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/BinaryCustomCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/BinaryCustomCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/BinaryCustomCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: BinaryCustomCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class BinaryCustomCommand extends CustomCommand { >+ >+ public BinaryCustomCommand() { >+ super(); >+ _tag = RA_BINARY_CUSTOM_COMMAND; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/AgentActiveException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/AgentActiveException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/AgentActiveException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/AgentActiveException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentActiveException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class AgentActiveException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 892731289626728413L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/QueryProcessListCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/QueryProcessListCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/QueryProcessListCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/QueryProcessListCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: QueryProcessListCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class QueryProcessListCommand extends CommandElement implements Constants { >+ >+ /** >+ * QueryProcessList constructor comment. >+ */ >+ public QueryProcessListCommand() { >+ super(); >+ _tag = RA_QUERY_PROCESS_LIST; >+ } >+ >+ /** >+ * getSize method comment. >+ */ >+ public int getSize() { >+ return super.getSize(); >+ } >+ >+ /** >+ * readFromBuffer method comment. >+ */ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ return super.readFromBuffer(buffer, offset); >+ } >+ >+ /** >+ * writeToBuffer method comment. >+ */ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ return super.writeToBuffer(buffer, offset); >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ManageFileCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ManageFileCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ManageFileCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ManageFileCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ManageFileCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ManageFileCommand extends CommandElement implements Constants { >+ public static final int GET = 0x01; >+ public static final int PUT = 0x02; >+ public static final int DELETE = 0x03; >+ >+ private long _operation; >+ private RAString _filename = new RAString("");; >+ >+ public ManageFileCommand() { >+ super(); >+ _tag = RA_MANAGE_FILE; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += sizeofLong; // operation >+ size += _filename.getSize(); >+ >+ return size; >+ } >+ >+ /** >+ * @return long - the operation >+ */ >+ public long getOperation() { >+ return _operation; >+ } >+ >+ /** >+ * @return RAString - the file name >+ */ >+ public String getFilename() { >+ if (_filename != null) >+ return _filename.getData(); >+ return null; >+ } >+ >+ /** >+ * set the operation to be performed. >+ * >+ * @param operation >+ */ >+ public void setOperation(long operation) { >+ _operation = operation; >+ } >+ >+ /** >+ * set file name to be passed to RAC >+ * >+ * @param filename >+ */ >+ public void setFilename(String filename) { >+ _filename = new RAString(filename); >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.readFromBuffer(buffer, current); >+ >+ _operation = Message.readRALongFromBuffer(buffer, current); >+ current += sizeofLong; >+ >+ current = Message.readRAStringFromBuffer(buffer, current, _filename); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _operation); >+ current = Message.writeRAStringToBuffer(buffer, current, _filename); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannelFactory.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannelFactory.java >diff -N src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannelFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/core/file/socket/ISocketChannelFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ISocketChannelFactory.java,v 1.5 2006/10/30 18:25:55 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.hyades.execution.core.file.socket; >+ >+import java.io.IOException; >+import java.net.InetSocketAddress; >+import java.net.Socket; >+ >+/** >+ * The socket channel factory creates socket channel objects given some seed information such as socket, real channel or connection information to establish a new socket channel. >+ * >+ * @author Scott E. Schneider >+ */ >+public interface ISocketChannelFactory { >+ /** >+ * Creates a local socket channel abstraction over a new socket to be established at the given internet socket address, basically connects to the address given, establishes a socket to the other side and returns back an abstraction to manipulate the connection with -- this method creates a new connection at the given address or returns back an existing connection that is not in use (with no contention with another client possible) >+ * >+ * @param address >+ * the address to establish a connection to >+ * @return a new socket channel to use >+ * @throws IOException >+ * throws an IO exception if socket problems arise >+ */ >+ public ISocketChannel create(InetSocketAddress address) throws IOException; >+ >+ /** >+ * Creates a local socket channel abstraction over a new socket to be established at the given internet socket address, basically connects to the address given, establishes a socket to the other side and returns back an abstraction to manipulate the connection with -- this method creates a new connection at the given address or returns back an existing connection that is not in use (with no contention with another client possible) >+ * >+ * @param address >+ * the address to establish a connection to >+ * @param timeout >+ * timeout to use for the connection >+ * @return a new socket channel to use >+ * @throws IOException >+ * throws an IO exception if socket problems arise >+ */ >+ public ISocketChannel create(InetSocketAddress address, int timeout) throws IOException; >+ >+ /** >+ * Creates a local socket channel abstraction for the given standard channel, this does not create a new connection, simply wraps a java.nio channel with a local abstraction >+ * >+ * @param realChannel >+ * the standard Java abstraction >+ * @return the local socket channel interface, abstracting the real socket channel and associated socket >+ */ >+ public ISocketChannel create(java.nio.channels.SocketChannel realChannel); >+ >+ /** >+ * Creates a local socket channel abstraction for the given socket, this does not create a new connection, simply wraps a java.nio channel with a local abstraction >+ * >+ * @param socket >+ * the socket to seed this socket channel >+ * @return the local socket channel interface abstacting an already existing socket >+ * @throws an >+ * IO exception if socket problems arise >+ */ >+ public ISocketChannel create(Socket socket) throws IOException; >+} >Index: src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannel.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannel.java >diff -N src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/core/file/socket/SocketChannel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,161 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: SocketChannel.java,v 1.4 2006/10/30 18:25:55 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.hyades.execution.core.file.socket; >+ >+import java.io.IOException; >+import java.net.Socket; >+import java.nio.ByteBuffer; >+import java.nio.channels.Channel; >+import java.nio.channels.Channels; >+import java.nio.channels.ReadableByteChannel; >+import java.nio.channels.WritableByteChannel; >+ >+/** >+ * An abstraction above the socket channel to allow a socket channel to be emulated by taking a readable byte channel and a writeable byte channel and combining them into a new interface. Socket channel is a class and not an interface in Java, so an interface and an adapter class implementation is introduced to satisfy our purposes. >+ * >+ * A socket channel instance can be created from a standard socket or from a standard channel. >+ * >+ * @see org.eclipse.hyades.execution.core.file.socket.ISocketChannel >+ * >+ * @author Scott E. Schneider >+ */ >+class SocketChannel implements ISocketChannel { >+ >+ /** >+ * An adapter that adapts a socket to look like a channel. A simple interface is exposed to clients with the is open and close methods. >+ * >+ * @author Scott E. Schneider >+ */ >+ private class ChannelInterfaceAdapter implements Channel { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.Channel#close() >+ */ >+ public void close() throws IOException { >+ SocketChannel.this.socket.close(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.Channel#isOpen() >+ */ >+ public boolean isOpen() { >+ return !SocketChannel.this.socket.isClosed(); >+ } >+ >+ } >+ >+ /** >+ * The channel interface where all channel interface calls are delegated to >+ */ >+ private final Channel channel; >+ >+ /** >+ * The readable byte channel, all readable byte channel interface invocations are delegated to this instance >+ */ >+ private final ReadableByteChannel readable; >+ >+ /** >+ * The underlying socket for this socket channel >+ */ >+ private final Socket socket; >+ >+ /** >+ * The writable byte channel, all writable byte channel interface invocations are delegate to this instance >+ */ >+ private final WritableByteChannel writable; >+ >+ /** >+ * For a standard "real" channel from java.nio, simply store the instance in three interface-held variables, used by the corresponding methods in this class to adapt the calls (just re-forward them into the appropriate delegates in most cases) >+ * >+ * @param realChannel >+ * the real channel obtained from the socket channel related classes in java.nio >+ */ >+ SocketChannel(java.nio.channels.SocketChannel realChannel) { >+ this.channel = realChannel; >+ this.readable = realChannel; >+ this.writable = realChannel; >+ this.socket = realChannel.socket(); >+ } >+ >+ /** >+ * A socket channel emulation is created given a standard socket, this constructor will take the socket, obtain input and output streams and then using the java.nio utility class it will create channels from these. For the main channel interface it will adapt these appropriately to the underlying socket here >+ * >+ * @param socket >+ * the socket that is abstracted by the socket channel instance >+ */ >+ SocketChannel(Socket socket) throws IOException { >+ this.channel = new ChannelInterfaceAdapter(); >+ this.readable = Channels.newChannel(socket.getInputStream()); >+ this.writable = Channels.newChannel(socket.getOutputStream()); >+ this.socket = socket; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.Channel#close() >+ */ >+ public void close() throws IOException { >+ if (this.socket != null) { >+ socket.close(); >+ } >+ if (this.channel != null) { >+ this.channel.close(); >+ } >+ if (this.readable != null) { >+ this.readable.close(); >+ } >+ if (this.writable != null) { >+ this.writable.close(); >+ } >+ } >+ >+ /** >+ * Returns the underlying socket for this socket channel >+ */ >+ public Socket getSocket() { >+ return this.socket; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.Channel#isOpen() >+ */ >+ public boolean isOpen() { >+ return this.channel.isOpen(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer) >+ */ >+ public int read(ByteBuffer buffer) throws IOException { >+ return this.readable.read(buffer); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer) >+ */ >+ public int write(ByteBuffer buffer) throws IOException { >+ return this.writable.write(buffer); >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Node.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Node.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Node.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Node.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,144 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Node.java,v 1.4 2006/12/14 23:11:18 jptoomey Exp $ >+ * >+ * Contributors: IBM - Initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.net.InetAddress; >+import java.util.Enumeration; >+ >+import org.eclipse.hyades.execution.security.ISecureClientParameters; >+import org.eclipse.hyades.execution.local.common.SetNVPairCommand; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+import org.eclipse.hyades.execution.security.User; >+ >+public interface Node extends CommandHandler { >+ >+ /** >+ * Terminates the specified process on this node. >+ */ >+ void killProcess(Process process) throws InactiveProcessException, >+ NotConnectedException; >+ >+ /** >+ * Causes this node to shutdown after the specified number of seconds. >+ */ >+ void shutdown(long delay) throws NotConnectedException; >+ >+ /** >+ * Causes this node to reboot after the specified number of seconds. >+ */ >+ void reboot(long delay) throws NotConnectedException; >+ >+ /** >+ * Enumerate all the monitors on this node. >+ */ >+ Enumeration listMonitors() throws NotConnectedException; >+ >+ /** >+ * Enumerate all the active processes on this node. >+ * >+ * This method has side effects of storing the process list within >+ * the node, populating the agents within each process in that list >+ * and retrieving the details of each agent in each process. >+ */ >+ Enumeration listProcesses() throws NotConnectedException; >+ >+ /** >+ * Enumerate all the active processes on this node. >+ * >+ * This method has side effects of storing the process list within >+ * the node and populating the agents within each process in that list >+ * Unlike the listProcesses() method, it does *not* retrieve the details >+ * for each agent. >+ */ >+ Enumeration fastListProcesses() throws NotConnectedException; >+ >+ /** >+ * Enumerate all the properties on this node. >+ */ >+ SetNVPairCommand[] getPropertyValues(String name, String type) >+ throws NotConnectedException; >+ >+ /** >+ * Retrieve a specific Process on this Node >+ */ >+ Process getProcess(String processId); >+ >+ /** >+ * Retrieve the InetAddress for this Node. >+ */ >+ InetAddress getInetAddress(); >+ >+ /** >+ * Retrives all the InetAddresses for this Node. >+ */ >+ InetAddress[] getAllInetAddresses(); >+ >+ /** >+ * Retrieve the host name for this Node. >+ */ >+ String getName(); >+ >+ /** >+ * Is this controller connected to this node >+ */ >+ boolean isConnected(); >+ >+ /** >+ * Attempt to connect to this node. >+ */ >+ Connection connect(int port) throws AgentControllerUnavailableException, >+ SecureConnectionRequiredException, >+ UntrustedAgentControllerException, LoginFailedException; >+ >+ /** >+ * Retrieve the connection associated with this node object >+ */ >+ Connection getConnection(); >+ >+ /** >+ * Retrieve the user for this node. >+ */ >+ User getUser(); >+ >+ /** >+ * Update the user for this node. >+ */ >+ void setUser(User user); >+ >+ /** >+ * Blocks calling thread until the process is retrieved, if the process >+ * cannot be retrieved within the timeout period, null is returned for the >+ * process return value. >+ * >+ * @param processIdentity >+ * the identity of the process to wait for >+ * @param timeout >+ * the maximum time to wait for the process to be retrieved >+ * @return the process retrieved or null if the timeout is reached before >+ * the process is found >+ * @throws NotConnectedException >+ */ >+ Process waitForProcess(String processIdentity, int timeout) >+ throws NotConnectedException, InactiveProcessException; >+ >+ void setApplication(Application app); >+ >+ Application getApplication(); >+ >+ void setSecurityParameters(ISecureClientParameters manager); >+ >+ ISecureClientParameters getSecurityParameters(); >+ >+} >+ >Index: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationSuccessfulCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationSuccessfulCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationSuccessfulCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AuthenticationSuccessfulCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AuthenticationSuccessfulCommand.java,v 1.4 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AuthenticationSuccessfulCommand extends CommandElement implements Constants { >+ private RAString _key = new RAString(""); >+ >+ public AuthenticationSuccessfulCommand() { >+ super(); >+ _tag = RA_AUTHENTICATION_SUCCESSFUL; >+ } >+ >+ public int getSize() { >+ int size = super.getSize(); >+ >+ size += _key.getSize(); >+ >+ return size; >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.readFromBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.readFromBuffer(buffer, current); >+ current = Message.readRAStringFromBuffer(buffer, current, _key); >+ >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = offset; >+ >+ /* >+ * Cannot call super.writeToBuffer() since this command does not have a >+ * context >+ */ >+ // current = super.writeToBuffer(buffer, current); >+ current = Message.writeRALongToBuffer(buffer, current, _tag); >+ current = Message.writeRAStringToBuffer(buffer, current, _key); >+ >+ return current; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/InactiveProcessException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/InactiveProcessException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/InactiveProcessException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/InactiveProcessException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: InactiveProcessException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class InactiveProcessException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 5117230334515885419L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Process.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Process.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Process.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Process.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,168 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Process.java,v 1.4 2005/09/27 20:31:58 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.util.Enumeration; >+ >+import org.eclipse.hyades.execution.local.common.Console; >+ >+public interface Process { >+ >+ /** >+ * Launches the process on the node that was provided to the ProcessFactory during construction of this Process instance. If the Process was already launched the ProcessActiveException is thrown. >+ */ >+ void launch() throws ProcessActiveException, NotConnectedException, NoSuchApplicationException; >+ >+ /** >+ * Kills this process if it is active. >+ */ >+ void kill(long delay) throws InactiveProcessException, NotConnectedException; >+ >+ /** >+ * Provides an Enumeration of all the Agents associated with this Process instance. >+ * >+ * @see Agent >+ */ >+ Enumeration listAgents(); >+ >+ /** >+ * Retrieves an agent based upon it's name >+ * >+ * @see Agent >+ * @return the agent with the specified name if it exists, null otherwise >+ */ >+ Agent getAgent(String name); >+ >+ /** >+ * Provides an enumeration of all the agents of a specific type that are assciated with this Process. >+ */ >+ Enumeration getAgentsByType(String type); >+ >+ /** >+ * Adds a ProcessListener to this Process instance. >+ * >+ * @see ProcessListener >+ */ >+ void addProcessListener(ProcessListener listener); >+ >+ /** >+ * Removes a ProcessListener from this Process instance. >+ * >+ * @see ProcessListener >+ */ >+ void removeProcessListener(ProcessListener listener); >+ >+ /** >+ * Retrieves the Node that this Process instance is associated with. >+ * >+ * @see Node >+ */ >+ Node getNode() throws InactiveProcessException; >+ >+ /** >+ * Save a user friendly name so that it can be retrieved later via Process#getName() >+ */ >+ void setName(String name); >+ >+ /** >+ * Retrieves the name of this process as provided by Process#setName() >+ */ >+ String getName(); >+ >+ /** >+ * Retrieves the uuid of this process if it is known, null otherwise. >+ */ >+ String getUUID(); >+ >+ void setUUID(String uuid); >+ >+ /** >+ * Set the exectauble name for this process. >+ */ >+ void setExecutable(String exe) throws ProcessActiveException; >+ >+ /** >+ * Get the exectable name for this process. >+ */ >+ String getExecutable(); >+ >+ /** >+ * Retrieve the process ID (pid) for this process >+ */ >+ String getProcessId() throws InactiveProcessException; >+ >+ void setProcessId(String pid); >+ >+ boolean isActive(); >+ >+ void setActive(boolean isActive); >+ >+ /** >+ * Retrieves the console of this Process instance. >+ */ >+ Console getConsole(); >+ >+ /** >+ * Adds an environment variable to this process. >+ */ >+ void addEnvironmentVariable(Variable variable) throws ProcessActiveException; >+ >+ /** >+ * Retrieves an environment variable from this process. >+ * >+ * @return the environment variable with the specified name attribute if it exists, null otherwise. >+ */ >+ Variable getEnvironmentVariable(String name); >+ >+ /** >+ * Removes an environment variable from this process. >+ */ >+ void removeEnvironmentVariable(Variable variable) throws ProcessActiveException; >+ >+ /** >+ * Provides an enumeration of each Variabe comprising the entire environment of this process. >+ * >+ * @see Variable >+ */ >+ Enumeration getEnvironment(); >+ >+ /** >+ * Set the parameters for this process >+ */ >+ void setParameters(String parameters) throws ProcessActiveException; >+ >+ /** >+ * Retrieves the parameters of the process. >+ */ >+ String getParameters(); >+ >+ /** >+ * Set's the home directory of the process. >+ */ >+ void setLocation(String location) throws ProcessActiveException; >+ >+ /** >+ * Blocks calling thread until the agent is retrieved, if the agent cannot be retrieved within the timeout period, null is returned for the agent return value. >+ * >+ * @param agentType >+ * the type of agent qualified the selection >+ * @param agentName >+ * the name of the agent to wait for >+ * @param timeout >+ * the maximum time to wait for the agent to be retrieved >+ * @return the agent retrieved or null if the timeout is reached before the agent is found >+ * @throws NotConnectedException >+ */ >+ Agent waitForAgent(String agentType, String agentName, int timeout) throws NotConnectedException, InactiveProcessException; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/ContextMapper.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/ContextMapper.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/ContextMapper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/ContextMapper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ContextMapper.java,v 1.4 2005/10/01 23:42:33 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class ContextMapper { >+ protected final static int MAPPING_INCREMENT = 10; >+ >+ protected ContextMap[] _map = new ContextMap[MAPPING_INCREMENT]; >+ protected int _mappingCount = 0; >+ protected int _maxMappingCount = 0; >+ >+ class ContextMap { >+ public long _context = 0; >+ public CommandHandler _handler = null; >+ public boolean _dirty = false; >+ } >+ >+ public ContextMapper() { >+ super(); >+ } >+ >+ public void addContext(long contextId, CommandHandler handler) { >+ synchronized (_map) { >+ if (_maxMappingCount == _map.length) { >+ increaseContextmappingCapacity(); >+ } >+ for (int i = _mappingCount; i >= 0; i--) { >+ if (_map[i] == null) { >+ _mappingCount++; >+ _maxMappingCount++; >+ _map[i] = new ContextMap(); >+ _map[i]._context = contextId; >+ _map[i]._handler = handler; >+ _map[i]._dirty = true; >+ return; >+ } else if (!_map[i]._dirty) { >+ _mappingCount++; >+ _map[i]._context = contextId; >+ _map[i]._handler = handler; >+ _map[i]._dirty = true; >+ return; >+ } >+ } >+ } >+ } >+ >+ public CommandHandler getHandler(long contextid) { >+ CommandHandler ch = null; >+ synchronized (_map) { >+ for (int i = _maxMappingCount - 1; i >= 0; i--) { >+ if (_map[i] == null) { >+ /* This should never happen */ >+ break; >+ } >+ if (_map[i]._context == contextid && _map[i]._dirty == true) { >+ ch = _map[i]._handler; >+ break; >+ } >+ } >+ } >+ return ch; >+ } >+ >+ protected void increaseContextmappingCapacity() { >+ synchronized (_map) { >+ ContextMap[] newMapper = new ContextMap[_maxMappingCount + MAPPING_INCREMENT]; >+ for (int i = 0; i < _maxMappingCount; i++) { >+ newMapper[i] = _map[i]; >+ } >+ _map = newMapper; >+ newMapper = null; >+ } >+ } >+ >+ public void removeContext(long contextId) { >+ synchronized (_map) { >+ for (int i = _maxMappingCount - 1; i >= 0; i--) { >+ if (_map[i]._context == contextId && _map[i]._dirty == true) { >+ _mappingCount--; >+ _map[i]._dirty = false; >+ _map[i]._handler = null; >+ break; >+ } >+ } >+ } >+ >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/AgentInactiveCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/AgentInactiveCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/AgentInactiveCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/AgentInactiveCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: AgentInactiveCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class AgentInactiveCommand extends DetailedAgentInfoCommand { >+ >+ /** >+ * VMExitingCommand constructor comment. >+ */ >+ public AgentInactiveCommand() { >+ super(); >+ _tag = RA_AGENT_INACTIVE; >+ } >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/ProcessExitedCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/ProcessExitedCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/ProcessExitedCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/ProcessExitedCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: ProcessExitedCommand.java,v 1.2 2005/02/25 22:17:09 hleung Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public class ProcessExitedCommand extends SimpleProcessCommand { >+ >+ public ProcessExitedCommand() { >+ super(); >+ _tag = RA_PROCESS_EXITED; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/NotConnectedException.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/NotConnectedException.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/NotConnectedException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/NotConnectedException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: NotConnectedException.java,v 1.4 2005/10/08 14:28:51 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+public class NotConnectedException extends Exception { >+ >+ /** >+ * Stream-Unique IDentifier (SUID) of this class >+ */ >+ private static final long serialVersionUID = 1657617474248494436L; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/control/Connection.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/control/Connection.java >diff -N src-local-public/org/eclipse/hyades/execution/local/control/Connection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/control/Connection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: Connection.java,v 1.3 2005/09/13 16:46:20 sschneid Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.control; >+ >+import java.io.IOException; >+ >+import org.eclipse.hyades.execution.local.common.ControlMessage; >+import org.eclipse.hyades.execution.security.AuthenticationListener; >+import org.eclipse.hyades.execution.security.LoginFailedException; >+import org.eclipse.hyades.execution.security.SecureConnectionRequiredException; >+import org.eclipse.hyades.execution.security.UntrustedAgentControllerException; >+ >+public interface Connection { >+ >+ void sendMessage(ControlMessage msg, CommandHandler handler) throws IOException; >+ >+ void disconnect(); >+ >+ Node getNode(); >+ >+ boolean isActive(); >+ >+ int getPort(); >+ >+ /** >+ * Adds a ConnectionListener to this Connection instance. >+ * >+ * @see ConnectionListener >+ */ >+ void addConnectionListener(ConnectionListener listener); >+ >+ /** >+ * Removes a ConnectionListener from this Connection instance. >+ * >+ * @see ConnectionListener >+ */ >+ void removeConnectionListener(ConnectionListener listener); >+ >+ /** >+ * Adds an AuthenticationListener to this connection. >+ * >+ * @see AuthenticationListener >+ */ >+ void addAuthenticationListener(AuthenticationListener listener); >+ >+ /** >+ * Removes an AuthenticationListener from this connection. >+ * >+ * @see AuthenticationListener >+ */ >+ void removeAuthenticationListener(AuthenticationListener listener); >+ >+ void connect(Node node, int port) throws IOException, SecureConnectionRequiredException, LoginFailedException, UntrustedAgentControllerException; >+ >+} >Index: src-local-public/org/eclipse/hyades/execution/local/common/DetailedAgentInfoCommand.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/local/common/DetailedAgentInfoCommand.java >diff -N src-local-public/org/eclipse/hyades/execution/local/common/DetailedAgentInfoCommand.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/local/common/DetailedAgentInfoCommand.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,80 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: DetailedAgentInfoCommand.java,v 1.5 2006/04/06 15:28:00 samwai Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.local.common; >+ >+public abstract class DetailedAgentInfoCommand extends DetailedProcessCommand implements Constants { >+ protected RAString _agentName = new RAString(""); >+ protected RAString _agentUUID = new RAString(""); >+ protected RAString _agentType = new RAString(""); >+ >+ /** >+ * ProcessInfoCommandEntry constructor comment. >+ */ >+ public DetailedAgentInfoCommand() { >+ super(); >+ } >+ >+ public String getAgentName() { >+ if (_agentName != null) >+ return _agentName.getData(); >+ return null; >+ } >+ >+ public void setAgentName(String name) { >+ _agentName = new RAString(name); >+ } >+ >+ public String getAgentType() { >+ if (_agentType != null) { >+ return _agentType.getData(); >+ } >+ return null; >+ } >+ >+ public void setAgentType(String type) { >+ _agentType = new RAString(type); >+ } >+ >+ public String getAgentUUID() { >+ if (_agentUUID != null) { >+ return _agentUUID.getData(); >+ } >+ return null; >+ } >+ >+ public void setAgentUUID(String uuid) { >+ _agentUUID = new RAString(uuid); >+ } >+ >+ public int getSize() { >+ return super.getSize() + _agentName.getSize() + _agentUUID.getSize() + _agentType.getSize(); >+ } >+ >+ public int readFromBuffer(byte[] buffer, int offset) { >+ int current = super.readFromBuffer(buffer, offset); >+ current = Message.readRAStringFromBuffer(buffer, current, _agentName); >+ current = Message.readRAStringFromBuffer(buffer, current, _agentUUID); >+ current = Message.readRAStringFromBuffer(buffer, current, _agentType); >+ return current; >+ } >+ >+ public int writeToBuffer(byte[] buffer, int offset) { >+ int current = super.writeToBuffer(buffer, offset); >+ >+ current = Message.writeRAStringToBuffer(buffer, current, _agentName); >+ current = Message.writeRAStringToBuffer(buffer, current, _agentUUID); >+ current = Message.writeRAStringToBuffer(buffer, current, _agentType); >+ >+ return current; >+ } >+} >Index: src-local-public/org/eclipse/hyades/execution/file/FileServiceConstants.java >=================================================================== >RCS file: src-local-public/org/eclipse/hyades/execution/file/FileServiceConstants.java >diff -N src-local-public/org/eclipse/hyades/execution/file/FileServiceConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-local-public/org/eclipse/hyades/execution/file/FileServiceConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * 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 >+ * $Id: FileServiceConstants.java,v 1.3 2005/05/20 22:53:09 jptoomey Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.execution.file; >+ >+/** >+ * @author Giridhar.S >+ * >+ * This interface defines constants required for implementing file service. >+ * >+ */ >+public interface FileServiceConstants { >+ >+ public final static int RA_BUFFER_SIZE = 1024; >+ >+ /* The static return values for possible exceptions we may have to catch */ >+ >+ public static final int RA_ERROR = -1; >+ public static final int SECURE_CONNECTION_REQUIRED_EXCEPTION = -2; >+ public static final int UNTRUSTED_AGENT_CONTROLLER_EXCEPTION = -3; >+ public static final int AGENT_CONTROLLER_UNAVAILABLE_EXCEPTION = -4; >+ public static final int LOGIN_FAILED_EXCEPTION = -5; >+ public static final int UNKNOWN_HOST_EXCEPTION = -6; >+ public static final int CONNECT_EXCEPTION = -7; >+ public final static int RA_FILE_NOT_FOUND_ERROR = -8; >+ public final static int RA_IO_ERROR = -9; >+ public final static int RA_BIND_EXCEPTION = -10; >+ >+ /* Values to represent the state of the file server */ >+ public final static int RA_FS_STATUS_OK = 0; >+ public final static int RA_FS_STATUS_ERROR = -1; >+ >+ /* Values to represent the initialization status of the file server */ >+ public final static int RA_FS_UNINITIALIZED = 0; >+ public final static int RA_FS_INITIALIZED = 1; >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 136985
: 60396 |
60397