Package co.cask.cdap.api.dataset

Examples of co.cask.cdap.api.dataset.DatasetSpecification


      result = getVerifier(DatasetCreationSpec.class).verify(appId, dataSetCreateSpec);
      if (!result.isSuccess()) {
        throw new RuntimeException(result.getMessage());
      }
      String dsName = dataSetCreateSpec.getInstanceName();
      DatasetSpecification existingSpec = dsFramework.getDatasetSpec(dsName);
      if (existingSpec != null && !existingSpec.getType().equals(dataSetCreateSpec.getTypeName())) {
          // New app trying to deploy an dataset with same instanceName but different Type than that of existing.
          throw new DataSetException
            (String.format("Cannot Deploy Dataset : %s with Type : %s : Dataset with different Type Already Exists",
                           dsName, dataSetCreateSpec.getTypeName()));
        }
View Full Code Here


  }

  @Override
  public IndexedObjectStore<?> getDataset(DatasetSpecification spec,
                                          Map<String, String> arguments, ClassLoader classLoader) throws IOException {
    DatasetSpecification tableSpec = spec.getSpecification("index");
    DatasetSpecification objectStoreSpec = spec.getSpecification("data");

    Table index = tableDef.getDataset(tableSpec, arguments, classLoader);
    ObjectStore<?> objectStore = objectStoreDef.getDataset(objectStoreSpec, arguments, classLoader);

    return new IndexedObjectStore(spec.getName(), objectStore, index);
View Full Code Here

  }

  @Override
  public IndexedTable getDataset(DatasetSpecification spec,
                                 Map<String, String> arguments, ClassLoader classLoader) throws IOException {
    DatasetSpecification tableInstance = spec.getSpecification("d");
    Table table = tableDef.getDataset(tableInstance, arguments, classLoader);

    DatasetSpecification indexTableInstance = spec.getSpecification("i");
    Table index = tableDef.getDataset(indexTableInstance, arguments, classLoader);

    String columnNamesToIndex = spec.getProperty(INDEX_COLUMNS_CONF_KEY);
    Preconditions.checkNotNull(columnNamesToIndex, "columnsToIndex must be specified");
    String[] columns = columnNamesToIndex.split(",");
View Full Code Here

  }

  @Override
  public ObjectStoreDataset<?> getDataset(DatasetSpecification spec,
                                          Map<String, String> arguments, ClassLoader classLoader) throws IOException {
    DatasetSpecification kvTableSpec = spec.getSpecification("objects");
    KeyValueTable table = tableDef.getDataset(kvTableSpec, arguments, classLoader);

    TypeRepresentation typeRep = GSON.fromJson(spec.getProperty("type"), TypeRepresentation.class);
    Schema schema = GSON.fromJson(spec.getProperty("schema"), Schema.class);
    return new ObjectStoreDataset(spec.getName(), table, typeRep, schema, classLoader);
View Full Code Here

  @GET
  @Path("/data/datasets/{name}")
  public void getInfo(HttpRequest request, final HttpResponder responder,
                      @PathParam("name") String name) {
    DatasetSpecification spec = instanceManager.get(name);
    if (spec == null) {
      responder.sendStatus(HttpResponseStatus.NOT_FOUND);
    } else {
      DatasetMeta info = new DatasetMeta(spec, implManager.getTypeInfo(spec.getType()), null);
      responder.sendJson(HttpResponseStatus.OK, info, DatasetMeta.class, GSON);
    }
  }
View Full Code Here

    DatasetInstanceConfiguration creationProperties = getInstanceConfiguration(request);

    LOG.info("Creating dataset {}, type name: {}, typeAndProps: {}",
             name, creationProperties.getTypeName(), creationProperties.getProperties());

    DatasetSpecification existing = instanceManager.get(name);
    if (existing != null) {
      String message = String.format("Cannot create dataset %s: instance with same name already exists %s",
                                     name, existing);
      LOG.warn(message);
      responder.sendError(HttpResponseStatus.CONFLICT, message);
View Full Code Here

                     @PathParam("name") String name) {
    DatasetInstanceConfiguration creationProperties = getInstanceConfiguration(request);

    LOG.info("Update dataset {}, type name: {}, typeAndProps: {}",
             name, creationProperties.getTypeName(), creationProperties.getProperties());
    DatasetSpecification existing = instanceManager.get(name);

    if (existing == null) {
      // update is true , but dataset instance does not exist, return 404.
      responder.sendError(HttpResponseStatus.NOT_FOUND,
                          String.format("Dataset Instance %s does not exist to update", name));
      return;
    }

    if (!existing.getType().equals(creationProperties.getTypeName())) {
      String  message = String.format("Cannot update dataset %s instance with a different type, existing type is %s",
                                      name, existing.getType());
      LOG.warn(message);
      responder.sendError(HttpResponseStatus.CONFLICT, message);
      return;
    }
View Full Code Here

      throw new InstanceConflictException("Dataset instance with name already exists: " + datasetInstanceName);
    }

    Preconditions.checkArgument(registry.hasType(datasetType), "Dataset type '%s' is not registered", datasetType);
    DatasetDefinition def = registry.get(datasetType);
    DatasetSpecification spec = def.configure(datasetInstanceName, props);
    instances.put(datasetInstanceName, spec);
    def.getAdmin(spec, null).create();
    instances.put(datasetInstanceName, spec);
    LOG.info("Created dataset {} of type {}", datasetInstanceName, datasetType);
  }
View Full Code Here

  }

  @Override
  public synchronized void updateInstance(String datasetInstanceName, DatasetProperties props)
    throws InstanceConflictException, IOException {
    DatasetSpecification oldSpec = instances.get(datasetInstanceName);
    if (oldSpec == null) {
      throw new InstanceConflictException("Dataset instance with name does not exist: " + datasetInstanceName);
    }
    String datasetType = oldSpec.getType();
    Preconditions.checkArgument(registry.hasType(datasetType), "Dataset type '%s' is not registered", datasetType);
    DatasetDefinition def = registry.get(datasetType);
    DatasetSpecification spec = def.configure(datasetInstanceName, props);
    instances.put(datasetInstanceName, spec);
    def.getAdmin(spec, null).upgrade();
  }
View Full Code Here

    return registry.hasType(typeName);
  }

  @Override
  public synchronized void deleteInstance(String datasetInstanceName) throws InstanceConflictException, IOException {
    DatasetSpecification spec = instances.remove(datasetInstanceName);
    DatasetDefinition def = registry.get(spec.getType());
    def.getAdmin(spec, null).drop();
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.api.dataset.DatasetSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.