Package com.gigaspaces.lrmi
Class DynamicSmartStub
java.lang.Object
com.gigaspaces.lrmi.DynamicSmartStub
- All Implemented Interfaces:
ProxyInvocationHandler,ILRMIProxy,Externalizable,Serializable,InvocationHandler,Remote
public class DynamicSmartStub
extends Object
implements ProxyInvocationHandler, InvocationHandler, Serializable, Remote, Externalizable, ILRMIProxy
This class represents dynamic smart stub of underlying transport protocol. Due the dynamic proxy
Proxy this class serves as Interceptor of invoked methods. The invoked method injected by
dynamic-proxy delegates to the direct reference reflection call of exported object, only in case
this DynamicSmartStub still handles a direct reference of exported object getLocalObjImpl(). If DynamicSmartStub is serializing, as part writeExternal(java.io.ObjectOutput) method the getLocalObjImpl() will be exported to
the underlying transport protocol. The serialization process is an indication for
DynamicSmartStub about exiting out side from local JVM.
On deserialization the
DynamicSmartStub will try to acquire the direct localObject reference from the underlying
transport protocol. If direct reference wasn't acquired, it means the stub instance is not in
local JVM. Every future injected method will be called remotely.
- Since:
- 5.2
- Author:
- Igor Goldenberg
- See Also:
-
Field Summary
FieldsFields inherited from interface com.gigaspaces.internal.reflection.ProxyInvocationHandler
INTERNAL_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClose the underline proxy connection and resources, this proxy will no longer be usable.voiddisable()Force this stub to be disabled (disconnected from its target)voidenable()Removes state of any previously calledILRMIProxy.disable()booleanEquals the DynamicSmartStub instances by direct obj reference if the stubs in local VM, otherwise equals by remoteObjIdstatic DynamicSmartStubprotected voidfinalize()Returns the connectionURL of exported remote object.longprotected MethodCachedInvocationHandlerreturns the initialized remote InvocationHandlerlonglonglonginthashCode()Processes a method invocation on a proxy instance and returns the result.Needed for standard java dynamic proxy.protected ObjectinvokeRemote(Object proxy, IMethod method, Object[] args) performs remote invocation methodbooleanisClosed()booleanbooleanisRemote()booleanvoidoverrideMethodsMetadata(Map<String, LRMIMethodMetadata> methodsMetadata) Overrides the LRMI methods metadata.voidstatic voidsimulatedDisconnectionByPID(int pid) static voidsimulatedReconnectionByPID(int pid) static voidthrowProxyClosedExeption(String connectionUrl) toString()void
-
Field Details
-
markProxyAsClosed
-
-
Constructor Details
-
DynamicSmartStub
public DynamicSmartStub()
-
-
Method Details
-
invoke
Needed for standard java dynamic proxy.- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
invoke
Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.- Specified by:
invokein interfaceProxyInvocationHandler- Parameters:
proxy- the proxy instance that the method was invoked onmethod- theIMethodinstance corresponding to the interface method invoked on the proxy instance. The declaring class of theIMethodobject will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.args- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornullif interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such asjava.lang.Integerorjava.lang.Boolean.- Returns:
- the value to return from the method invocation on the proxy instance. If the
declared return type of the interface method is a primitive type, then the value returned by
this method must be an instance of the corresponding primitive wrapper class; otherwise, it
must be a type assignable to the declared return type. If the value returned by this method
is
nulland the interface method's return type is primitive, then aNullPointerExceptionwill be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, aClassCastExceptionwill be thrown by the method invocation on the proxy instance. - Throws:
Throwable- the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in thethrowsclause of the interface method or to the unchecked exception typesjava.lang.RuntimeExceptionorjava.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in thethrowsclause of the interface method, then anUndeclaredThrowableExceptioncontaining the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.- See Also:
-
invokeRemote
performs remote invocation method- Throws:
Throwable
-
getInvocationHandler
returns the initialized remote InvocationHandler- Throws:
RemoteException
-
getRemoteObjID
public long getRemoteObjID()- Returns:
- the remote objID
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
getLocalObjImpl
- Returns:
- The instance of local object impl, or
nullif this Stub doesn't exist in local exported VM
-
extractDynamicSmartStubFrom
- Parameters:
obj- the object to extract DynamicSmartStub instance.- Returns:
- the extracted DynamicSmartStub instance or
nullsupplied object is not DynamicSmartStub invocation handler and notProxy.
-
isCollocated
public boolean isCollocated()- Returns:
trueif this instance of DynamicSmartStub is collocated with exported endpoint object, otherwisefalseif this stub is remote.
-
hashCode
public int hashCode() -
equals
Equals the DynamicSmartStub instances by direct obj reference if the stubs in local VM, otherwise equals by remoteObjId -
isUnexported
public boolean isUnexported()- Returns:
trueif DynamicSmartStub was closed
-
closeProxy
public void closeProxy()Description copied from interface:ILRMIProxyClose the underline proxy connection and resources, this proxy will no longer be usable.- Specified by:
closeProxyin interfaceILRMIProxy
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceILRMIProxy- Returns:
- true if this proxy is closed.
-
isRemote
public boolean isRemote()- Specified by:
isRemotein interfaceILRMIProxy- Returns:
- whether this proxy is connected to a remote stub
-
getServicePlatformLogicalVersion
- Specified by:
getServicePlatformLogicalVersionin interfaceILRMIProxy- Returns:
- returns the logical version of the service
-
getGeneratedTraffic
public long getGeneratedTraffic()- Specified by:
getGeneratedTrafficin interfaceILRMIProxy- Returns:
- entire traffic generated by this proxy in bytes, this number is not necessarily monotonic as each connection in the stub holds this data per connection, once this connection is disconnected/reconnected this data is reseted.
-
getReceivedTraffic
public long getReceivedTraffic()- Specified by:
getReceivedTrafficin interfaceILRMIProxy- Returns:
- entire traffic received by this proxy in bytes this number is not necessarily monotonic as each connection in the stub holds this data per connection, once this connection is disconnected/reconnected this data is reseted.
-
getConnectionUrl
Returns the connectionURL of exported remote object.- Specified by:
getConnectionUrlin interfaceILRMIProxy- Returns:
- the unique connectionURL of exported remote object. This URL contains [Protocol]://[ServerEndPointIP:Port]/[RemoteObjectUID]_[StubSeqID] Example: NIO://192.168.0.100:61754/1164059001211_0
-
getRemoteProcessId
public long getRemoteProcessId()- Specified by:
getRemoteProcessIdin interfaceILRMIProxy- Returns:
- the process id of the stub
-
getRemoteHostName
- Specified by:
getRemoteHostNamein interfaceILRMIProxy- Returns:
- return the host name of the stub
-
getRemoteHostAddress
- Specified by:
getRemoteHostAddressin interfaceILRMIProxy- Returns:
- return the host address of the stub
-
getRemoteNetworkAddress
- Specified by:
getRemoteNetworkAddressin interfaceILRMIProxy- Returns:
- the ip address + port of the stub
-
toString
-
getStubId
- Specified by:
getStubIdin interfaceILRMIProxy- Returns:
- the stub id
-
disable
Description copied from interface:ILRMIProxyForce this stub to be disabled (disconnected from its target)- Specified by:
disablein interfaceILRMIProxy- Throws:
RemoteException
-
enable
Description copied from interface:ILRMIProxyRemoves state of any previously calledILRMIProxy.disable()- Specified by:
enablein interfaceILRMIProxy- Throws:
RemoteException
-
overrideMethodsMetadata
Description copied from interface:ILRMIProxyOverrides the LRMI methods metadata. Can only be used before first invocation.- Specified by:
overrideMethodsMetadatain interfaceILRMIProxy
-
throwProxyClosedExeption
- Throws:
ProxyClosedException
-
getMonitoringDetails
-
finalize
-
simulatedDisconnectionByPID
public static void simulatedDisconnectionByPID(int pid) -
simulatedReconnectionByPID
public static void simulatedReconnectionByPID(int pid)
-