Author: mturk
Date: Tue Aug 9 09:29:08 2011
New Revision: 1155282
URL: http://svn.apache.org/viewvc?rev=1155282&view=rev
Log:
IPC endpoints do not support Selectors
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Endpoint.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointType.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpoint.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpointAddress.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcServerEndpoint.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Endpoint.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Endpoint.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Endpoint.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Endpoint.java
Tue Aug 9 09:29:08 2011
@@ -26,6 +26,7 @@ import java.net.SocketException;
import org.apache.commons.runtime.io.ClosedDescriptorException;
import org.apache.commons.runtime.io.Descriptor;
import org.apache.commons.runtime.io.Stream;
+import org.apache.commons.runtime.OperationNotImplementedException;
import org.apache.commons.runtime.OverflowException;
/**
@@ -155,12 +156,15 @@ public abstract class Endpoint implement
* @throws ClosedSelectorException if the selector is closed.
* @throws IllegalSelectorException if the key was not created by the same
* selector as this selector.
+ * @throws OperationNotImplementedException if the endpoint doesn't
+ * support selections.
* @throws OverflowException if the selector reached it's capacity.
*/
public abstract SelectionKey register(Selector selector, int ops, Object
att)
throws ClosedSelectorException,
IllegalSelectorException,
ClosedDescriptorException,
+ OperationNotImplementedException,
OverflowException,
IOException;
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointType.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointType.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointType.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointType.java
Tue Aug 9 09:29:08 2011
@@ -24,8 +24,11 @@ public enum EndpointType
UNSPEC( 0),
/** Socket */
SOCKET( 1),
- /** Unix domain socket or Windows pipe */
- LOCAL( 2);
+ /** Unix domain socket or Windows localhost
+ */
+ LOCAL( 2),
+ /** Platform specific IPC implementation. */
+ CUSTOM( 3);
private int value;
private EndpointType(int v)
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpoint.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpoint.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpoint.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpoint.java
Tue Aug 9 09:29:08 2011
@@ -30,6 +30,7 @@ import org.apache.commons.runtime.io.Ope
import org.apache.commons.runtime.io.Stream;
import org.apache.commons.runtime.Errno;
import org.apache.commons.runtime.Status;
+import org.apache.commons.runtime.OperationNotImplementedException;
import org.apache.commons.runtime.OverflowException;
import org.apache.commons.runtime.TimeoutException;
@@ -44,7 +45,6 @@ public class IpcEndpoint extends Connect
{
private final IpcDescriptor sd;
private EndpointAddress ea;
- private SelectionKeyImpl key;
private boolean connected = false;
private IpcStream stream = null;
private static native int connect0(long fd, byte[] sa, int
timeout);
@@ -54,7 +54,7 @@ public class IpcEndpoint extends Connect
*/
public IpcEndpoint()
{
- super(EndpointType.LOCAL);
+ super(EndpointType.CUSTOM);
this.sd = new IpcDescriptor();
}
@@ -64,7 +64,7 @@ public class IpcEndpoint extends Connect
*/
public IpcEndpoint(Descriptor sd, EndpointAddress ea)
{
- super(EndpointType.LOCAL);
+ super(EndpointType.CUSTOM);
if (sd == null || ea == null)
throw new NullPointerException();
this.sd = (IpcDescriptor)sd;
@@ -115,8 +115,6 @@ public class IpcEndpoint extends Connect
IllegalBlockingModeException,
IOException
{
- if (key != null && key.selected)
- throw new IllegalBlockingModeException();
return sd.configureBlocking(block);
}
@@ -128,52 +126,21 @@ public class IpcEndpoint extends Connect
connected = false;
if (sd.valid()) {
- if (key != null && key.selected) {
- try {
- key.cancel();
- } catch (Exception e) {
- // Ignore selector exceptions
- }
- }
sd.close();
}
- if (key != null) {
- key.reset();
- key = null;
- }
}
@Override
public SelectionKey keyFor(Selector selector)
{
- if (key != null && key.selector == selector && key.ievents != 0)
- return key;
- else
- return null;
+ return null;
}
@Override
public SelectionKey register(Selector selector, int ops, Object att)
- throws ClosedSelectorException,
- IllegalSelectorException,
- ClosedDescriptorException,
- OverflowException,
- IOException
+ throws OperationNotImplementedException
{
- if (sd.closed())
- throw new ClosedDescriptorException();
- AbstractSelector sel = (AbstractSelector)selector;
- //
- // If key.ievents is zero, this means that the
- // key was invalidated by Selector.close().
- // In that case create a new key instance.
- if (key == null || key.ievents == 0)
- key = new SelectionKeyImpl(sel, this);
- if (key.selector != sel)
- throw new IllegalSelectorException();
- if (att != null)
- key.attach(att);
- return key.queue(ops & 0x000f);
+ throw new OperationNotImplementedException();
}
@Override
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpointAddress.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpointAddress.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpointAddress.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcEndpointAddress.java
Tue Aug 9 09:29:08 2011
@@ -52,20 +52,7 @@ public final class IpcEndpointAddress ex
super(AddressFamily.LOCAL);
if (name == null || name.length() == 0)
throw new InvalidArgumentException();
- super.sa = sockaddr0("Global\\" + name);
- }
-
- /**
- * Create a new local socket adrress.
- */
- public IpcEndpointAddress(File path)
- throws NetworkException, InvalidArgumentException
- {
- super(AddressFamily.LOCAL);
- String name = "Global\\" + path.getPath();
- if (name == null || name.length() == 0)
- throw new InvalidArgumentException();
- super.sa = sockaddr0(name);
+ super.sa = sockaddr0("Global\\" + name.replace('\\', '_'));
}
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcServerEndpoint.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcServerEndpoint.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcServerEndpoint.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcServerEndpoint.java
Tue Aug 9 09:29:08 2011
@@ -27,6 +27,7 @@ import org.apache.commons.runtime.io.Clo
import org.apache.commons.runtime.io.Descriptor;
import org.apache.commons.runtime.io.OperationInProgressException;
import org.apache.commons.runtime.io.OperationWouldBlockException;
+import org.apache.commons.runtime.OperationNotImplementedException;
import org.apache.commons.runtime.OverflowException;
import org.apache.commons.runtime.Status;
@@ -41,7 +42,6 @@ public class IpcServerEndpoint extends S
{
private static final int LISTEN_BACKLOG = 50;
private final IpcDescriptor sd;
- private SelectionKeyImpl key;
private EndpointAddress sa;
private boolean bound = false;
private boolean blocking = true;
@@ -52,7 +52,7 @@ public class IpcServerEndpoint extends S
*/
public IpcServerEndpoint()
{
- super(EndpointType.LOCAL);
+ super(EndpointType.CUSTOM);
this.sd = new IpcDescriptor();
}
@@ -62,7 +62,7 @@ public class IpcServerEndpoint extends S
*/
public IpcServerEndpoint(Descriptor sd)
{
- super(EndpointType.LOCAL);
+ super(EndpointType.CUSTOM);
if (sd == null)
throw new NullPointerException();
this.sd = (IpcDescriptor)sd;
@@ -86,8 +86,6 @@ public class IpcServerEndpoint extends S
throws IllegalBlockingModeException,
IOException
{
- if (key != null && key.selected)
- throw new IllegalBlockingModeException();
// Blocking mode must be set before the
// actual server endpoint is created.
if (sd.valid())
@@ -103,29 +101,15 @@ public class IpcServerEndpoint extends S
{
synchronized(mutex) {
if (sd.valid()) {
- if (key != null && key.selected) {
- try {
- key.cancel();
- } catch (Exception e) {
- // Ignore selector exceptions
- }
- }
sd.close();
}
- if (key != null) {
- key.reset();
- key = null;
- }
}
}
@Override
public SelectionKey keyFor(Selector selector)
{
- if (key != null && key.selector == selector && key.ievents != 0)
- return key;
- else
- return null;
+ return null;
}
@Override
@@ -136,21 +120,7 @@ public class IpcServerEndpoint extends S
OverflowException,
IOException
{
- ops = ops & 0x000f;
- if (sd.closed())
- throw new ClosedDescriptorException();
- AbstractSelector sel = (AbstractSelector)selector;
- //
- // If key.ievents is zero, this means that the
- // key was invalidated by Selector.close().
- // In that case create a new key instance.
- if (key == null || key.ievents == 0)
- key = new SelectionKeyImpl(sel, this);
- if (key.selector != sel)
- throw new IllegalSelectorException();
- if (att != null)
- key.attach(att);
- return key.queue(ops);
+ throw new OperationNotImplementedException();
}
private static native int bind0(long fd, byte[] sa, int backlog);
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java?rev=1155282&r1=1155281&r2=1155282&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsSemaphore.java
Tue Aug 9 09:29:08 2011
@@ -66,7 +66,7 @@ final class WindowsSemaphore extends Sem
this.name = "Global\\" + name.replace('\\', '_');
long sa = Security.getSecurityDescriptor(SEMAPHORE_ALL_ACCESS |
AccessRights.GENERIC_RWX,
SEMAPHORE_ALL_ACCESS |
AccessRights.GENERIC_RWX,
- SEMAPHORE_MODIFY_STATE |
AccessRights.GENERIC_RWR);
+ SEMAPHORE_MODIFY_STATE |
AccessRights.SYNCHRONIZE | AccessRights.GENERIC_RWR);
handle = create0(this.name, value, sa);
owner = true;
}