use of org.apache.zeppelin.resource.RemoteResource in project zeppelin by apache.
the class RemoteInterpreterEventClient method invokeMethod.
/**
* Invoke method and save result in resourcePool as another resource
*
* @param resourceId
* @param methodName
* @param paramTypes
* @param params
* @param returnResourceName
* @return
*/
@Override
public Resource invokeMethod(ResourceId resourceId, String methodName, Class[] paramTypes, Object[] params, String returnResourceName) {
LOGGER.debug("Request Invoke method {} of Resource {}", methodName, resourceId.getName());
InvokeResourceMethodEventMessage invokeMethod = new InvokeResourceMethodEventMessage(resourceId, methodName, paramTypes, params, returnResourceName);
try {
ByteBuffer serializedResource = callRemoteFunction(client -> client.invokeMethod(intpGroupId, invokeMethod.toJson()));
Resource deserializedResource = (Resource) Resource.deserializeObject(serializedResource);
RemoteResource remoteResource = RemoteResource.fromJson(GSON.toJson(deserializedResource));
remoteResource.setResourcePoolConnector(this);
return remoteResource;
} catch (IOException | ClassNotFoundException e) {
LOGGER.error("Failed to invoke method", e);
return null;
}
}
use of org.apache.zeppelin.resource.RemoteResource in project zeppelin by apache.
the class RemoteInterpreterEventClient method getAllResources.
/**
* Get all resources except for specific resourcePool
*
* @return
*/
@Override
public ResourceSet getAllResources() {
try {
List<String> resources = callRemoteFunction(client -> client.getAllResources(intpGroupId));
ResourceSet resourceSet = new ResourceSet();
for (String res : resources) {
RemoteResource resource = RemoteResource.fromJson(res);
resource.setResourcePoolConnector(this);
resourceSet.add(resource);
}
return resourceSet;
} catch (Exception e) {
LOGGER.warn("Fail to getAllResources", e);
return null;
}
}
Aggregations