Search in sources :

Example 11 with ResourcePool

use of org.apache.zeppelin.resource.ResourcePool in project SSM by Intel-bigdata.

the class Paragraph method getInterpreterContext.

private InterpreterContext getInterpreterContext(InterpreterOutput output) {
    AngularObjectRegistry registry = null;
    ResourcePool resourcePool = null;
    if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
        InterpreterSetting intpGroup = interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
        registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
        resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
    }
    List<InterpreterContextRunner> runners = new LinkedList<>();
    for (Paragraph p : note.getParagraphs()) {
        runners.add(new ParagraphRunner(note, note.getId(), p.getId()));
    }
    final Paragraph self = this;
    Credentials credentials = note.getCredentials();
    if (authenticationInfo != null) {
        UserCredentials userCredentials = credentials.getUserCredentials(authenticationInfo.getUser());
        authenticationInfo.setUserCredentials(userCredentials);
    }
    InterpreterContext interpreterContext = new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(), this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry, resourcePool, runners, output);
    return interpreterContext;
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) UserCredentials(org.apache.zeppelin.user.UserCredentials) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) UserCredentials(org.apache.zeppelin.user.UserCredentials) Credentials(org.apache.zeppelin.user.Credentials)

Example 12 with ResourcePool

use of org.apache.zeppelin.resource.ResourcePool in project SSM by Intel-bigdata.

the class Paragraph method getInterpreterContextWithoutRunner.

private InterpreterContext getInterpreterContextWithoutRunner(InterpreterOutput output) {
    AngularObjectRegistry registry = null;
    ResourcePool resourcePool = null;
    if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
        InterpreterSetting intpGroup = interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
        registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
        resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
    }
    List<InterpreterContextRunner> runners = new LinkedList<>();
    final Paragraph self = this;
    Credentials credentials = note.getCredentials();
    if (authenticationInfo != null) {
        UserCredentials userCredentials = credentials.getUserCredentials(authenticationInfo.getUser());
        authenticationInfo.setUserCredentials(userCredentials);
    }
    InterpreterContext interpreterContext = new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(), this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry, resourcePool, runners, output);
    return interpreterContext;
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) UserCredentials(org.apache.zeppelin.user.UserCredentials) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) UserCredentials(org.apache.zeppelin.user.UserCredentials) Credentials(org.apache.zeppelin.user.Credentials)

Example 13 with ResourcePool

use of org.apache.zeppelin.resource.ResourcePool in project SSM by Intel-bigdata.

the class Helium method suggestApp.

public HeliumPackageSuggestion suggestApp(Paragraph paragraph) {
    HeliumPackageSuggestion suggestion = new HeliumPackageSuggestion();
    Interpreter intp = paragraph.getCurrentRepl();
    if (intp == null) {
        return suggestion;
    }
    ResourcePool resourcePool = intp.getInterpreterGroup().getResourcePool();
    ResourceSet allResources;
    if (resourcePool != null) {
        if (resourcePool instanceof DistributedResourcePool) {
            allResources = ((DistributedResourcePool) resourcePool).getAll(true);
        } else {
            allResources = resourcePool.getAll();
        }
    } else {
        allResources = ResourcePoolUtils.getAllResources();
    }
    for (List<HeliumPackageSearchResult> pkgs : getAllPackageInfo().values()) {
        for (HeliumPackageSearchResult pkg : pkgs) {
            if (pkg.getPkg().getType() == HeliumPackage.Type.APPLICATION && pkg.isEnabled()) {
                ResourceSet resources = ApplicationLoader.findRequiredResourceSet(pkg.getPkg().getResources(), paragraph.getNote().getId(), paragraph.getId(), allResources);
                if (resources == null) {
                    continue;
                } else {
                    suggestion.addAvailablePackage(pkg);
                }
                break;
            }
        }
    }
    suggestion.sort();
    return suggestion;
}
Also used : Interpreter(org.apache.zeppelin.interpreter.Interpreter) ResourcePool(org.apache.zeppelin.resource.ResourcePool) DistributedResourcePool(org.apache.zeppelin.resource.DistributedResourcePool) ResourceSet(org.apache.zeppelin.resource.ResourceSet) DistributedResourcePool(org.apache.zeppelin.resource.DistributedResourcePool)

Example 14 with ResourcePool

use of org.apache.zeppelin.resource.ResourcePool in project zeppelin by apache.

the class ZeppelinContext method remove.

/**
   * Remove object from resourcePool
   * @param name
   */
@ZeppelinApi
public void remove(String name) {
    ResourcePool resourcePool = interpreterContext.getResourcePool();
    resourcePool.remove(name);
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi)

Example 15 with ResourcePool

use of org.apache.zeppelin.resource.ResourcePool in project zeppelin by apache.

the class ZeppelinContext method put.

/**
   * Add object into resource pool
   * @param name
   * @param value
   */
@ZeppelinApi
public void put(String name, Object value) {
    ResourcePool resourcePool = interpreterContext.getResourcePool();
    resourcePool.put(name, value);
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi)

Aggregations

ResourcePool (org.apache.zeppelin.resource.ResourcePool)27 Resource (org.apache.zeppelin.resource.Resource)11 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)9 Gson (com.google.gson.Gson)6 TException (org.apache.thrift.TException)6 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)6 ResourceSet (org.apache.zeppelin.resource.ResourceSet)6 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)5 Client (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService.Client)5 ByteBuffer (java.nio.ByteBuffer)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 AngularObject (org.apache.zeppelin.display.AngularObject)4 Credentials (org.apache.zeppelin.user.Credentials)4 UserCredentials (org.apache.zeppelin.user.UserCredentials)4 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 TypeToken (com.google.gson.reflect.TypeToken)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2