Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

Commit

Permalink
Finish 0.1.1
Browse files Browse the repository at this point in the history
Conflicts:
	sandbox/stratio_sandbox_module
  • Loading branch information
mafernandez-stratio committed Dec 4, 2014
2 parents af45ded + 822d472 commit 69673f1
Show file tree
Hide file tree
Showing 57 changed files with 795 additions and 405 deletions.
14 changes: 8 additions & 6 deletions _doc/Grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Table of contents
- [Main characteristics](#main-characteristics)
- [Language Features](#language-features)
- [Statements](#statements)
- [ADD DATASTORE](#add-dataStore)
- [DROP DATASTORE](#drop-dataStore)
- [ADD DATASTORE](#add-datastore)
- [DROP DATASTORE](#drop-datastore)
- [ADD CONNECTOR](#add-connector)
- [DROP CONNECTOR](#drop-connector)
- [ATTACH CLUSTER](#attach-cluster)
Expand All @@ -30,6 +30,7 @@ Table of contents
- [CREATE CATALOG](#create-catalog)
- [ALTER CATALOG](#alter-catalog)
- [DROP CATALOG](#drop-catalog)
- [USE] (#use)
- [CREATE TABLE](#create-table)
- [ALTER TABLE] (#alter-table)
- [UPDATE TABLE] (#update-table)
Expand Down Expand Up @@ -137,6 +138,7 @@ language .
- \<catalog\_name\> ::= \<identifier\>
- \<tablename\> ::= (\<catalog\_name\> '.')? \<identifier\>
- \<columnname\> ::= (\<tablename\> '.')? \<identifier\>
- \<indexname\> ::= \<tablename\> '.' \<identifier\>
- \<properties\> ::= \<property\> (AND \<property\>)\*
- \<property\> ::= (\<literal\> | \<identifier\> ) '=' ( \<literal\> | \<constant\> )
- \<data-types\> = TEXT | BIGINT | INT | DOUBLE | FLOAT | BOOLEAN
Expand Down Expand Up @@ -299,7 +301,7 @@ UPDATE \<tablename\>

Example:

UPDATE TABLE tableTest SET value = value + 900 WHERE age > 30;
UPDATE tableTest SET value = value + 900 WHERE age > 30;

### DROP TABLE

Expand Down Expand Up @@ -350,11 +352,11 @@ Example:

### DROP INDEX

DROP INDEX (IF EXISTS)? \<index-name\> ';'
DROP INDEX (IF EXISTS)? \<indexname\> ';'

Example:

DROP INDEX IF EXISTS revenueIndex;;
DROP INDEX IF EXISTS tabletest.revenueIndex;

### SELECT

Expand Down Expand Up @@ -410,7 +412,7 @@ Example:

### CLEAN METADATA

Remove all metadata related to catalogs, tables, indexes and columns.
Remove all apiManager related to catalogs, tables, indexes and columns.

CLEAN METADATA;

Expand Down
6 changes: 3 additions & 3 deletions _doc/InMemory-Connector-Development-Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ manifest schemas.
Implementing IMetadataEngine
----------------------------

The *IMetadataEngine* interface defines the set of operations related to metadata management that a connector may
The *IMetadataEngine* interface defines the set of operations related to metadata management that a connector may
provide to Crossdata. Notice that not all operations must be supported by the connector implementation,
only those defined in the *SupportedOperations* section of the connector manifest. In our case, we will provide
implementations for *createCatalog, *createTable*, *dropCatalog*, and *dropTable*. This connector will not support
Expand Down Expand Up @@ -453,8 +453,8 @@ The connector can be started in two different ways:
1. Running the connector tests:

> mvn clean verify -DconnectorJar="[CrossdataPath]/crossdata-connector-inmemory/target/crossdata-connector
-inmemory-0.1.1-RC1.jar" -DconnectorDefinition="[CrossdataPath]/crossdata-connector-inmemory/target/crossdata
-connector-inmemory-0.1.1-RC1/conf/InMemoryConnector.xml" -DclusterOptions="[TableRowLimit-100]"
-inmemory-0.1.1.jar" -DconnectorDefinition="[CrossdataPath]/crossdata-connector-inmemory/target/crossdata
-connector-inmemory-0.1.1/conf/InMemoryConnector.xml" -DclusterOptions="[TableRowLimit-100]"
-DconnectorCluster="TestCluster" -DconnectorMainClass="com.stratio.connector.inmemory.InMemoryConnector"

2. Starting the connector with maven:
Expand Down
2 changes: 1 addition & 1 deletion crossdata-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.stratio.crossdata</groupId>
<artifactId>crossdata-parent</artifactId>
<version>0.1.1-RC1</version>
<version>0.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ public ApiException(String error, Throwable cause) {
super(error, cause);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@

package com.stratio.crossdata.common.metadata;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.stratio.crossdata.common.data.CatalogName;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.ConnectorName;
import com.stratio.crossdata.common.data.DataStoreName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.ManifestException;
import com.stratio.crossdata.common.statements.structures.Selector;

public class ClusterMetadata implements IMetadata {
Expand All @@ -36,13 +42,32 @@ public class ClusterMetadata implements IMetadata {
private final DataStoreName dataStoreRef;
private Map<Selector, Selector> options;
private Map<ConnectorName, ConnectorAttachedMetadata> connectorAttachedRefs;
private Set<CatalogName> persistedCatalogs;

public ClusterMetadata(ClusterName name, DataStoreName dataStoreRef, Map<Selector, Selector> options,
Map<ConnectorName, ConnectorAttachedMetadata> connectorAttachedRefs) {
this.name = name;
this.options = options;
Map<ConnectorName, ConnectorAttachedMetadata> connectorAttachedRefs) throws ManifestException {

if(name.getName().isEmpty()){
throw new ManifestException(new ExecutionException("Tag name cannot be empty"));
} else {
this.name = name;
}

if(options == null){
this.options = new HashMap<>();
} else {
this.options = options;
}

this.dataStoreRef = dataStoreRef;
this.connectorAttachedRefs = connectorAttachedRefs;

if(connectorAttachedRefs == null){
this.connectorAttachedRefs = new HashMap<>();
} else {
this.connectorAttachedRefs = connectorAttachedRefs;
}

this.persistedCatalogs = new HashSet<>();
}

public ClusterName getName() {
Expand All @@ -69,4 +94,16 @@ public void setConnectorAttachedRefs(
public void setOptions(Map<Selector, Selector> options) {
this.options = options;
}

public Set<CatalogName> getPersistedCatalogs() {
return persistedCatalogs;
}

public void addPersistedCatalog(CatalogName persistedCatalog) {
this.persistedCatalogs.add(persistedCatalog);
}

public void removePersistedCatalog(CatalogName catalog) {
this.persistedCatalogs.remove(catalog);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import java.util.Map;
import java.util.Set;

import com.stratio.crossdata.common.data.ConnectorStatus;
import com.stratio.crossdata.common.manifest.ManifestHelper;
import com.stratio.crossdata.common.manifest.PropertyType;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.ConnectorName;
import com.stratio.crossdata.common.data.ConnectorStatus;
import com.stratio.crossdata.common.data.DataStoreName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.ManifestException;
import com.stratio.crossdata.common.manifest.ManifestHelper;
import com.stratio.crossdata.common.manifest.PropertyType;
import com.stratio.crossdata.common.statements.structures.Selector;

/**
Expand Down Expand Up @@ -88,6 +90,11 @@ public class ConnectorMetadata implements IMetadata {
*/
private Set<Operations> supportedOperations;

/**
* Whether the manifest of this connector was already added or not
*/
private boolean manifestAdded = false;

/**
* Class constructor.
*
Expand All @@ -102,7 +109,7 @@ public class ConnectorMetadata implements IMetadata {
public ConnectorMetadata(ConnectorName name, String version, Set<DataStoreName> dataStoreRefs,
Map<ClusterName, Map<Selector, Selector>> clusterProperties,
Set<PropertyType> requiredProperties, Set<PropertyType> optionalProperties,
Set<Operations> supportedOperations) {
Set<Operations> supportedOperations) throws ManifestException {
this(name, version, dataStoreRefs, clusterProperties, ConnectorStatus.OFFLINE, null, requiredProperties,
optionalProperties,
supportedOperations);
Expand All @@ -127,11 +134,22 @@ public ConnectorMetadata(ConnectorName name, String version,
String actorRef,
Set<PropertyType> requiredProperties,
Set<PropertyType> optionalProperties,
Set<Operations> supportedOperations) {
Set<Operations> supportedOperations) throws ManifestException {

if(name.getName().isEmpty()){
throw new ManifestException(new ExecutionException("Tag name cannot be empty"));
} else {
this.name = name;
}

this.name = name;
this.version = version;
this.dataStoreRefs = dataStoreRefs;

if(dataStoreRefs == null){
this.dataStoreRefs = new HashSet<>();
} else {
this.dataStoreRefs = dataStoreRefs;
}

this.clusterProperties = (clusterProperties!=null)?
clusterProperties:
new HashMap<ClusterName, Map<Selector, Selector>>();
Expand All @@ -154,24 +172,44 @@ public ConnectorMetadata(ConnectorName name, String version,
*/
public ConnectorMetadata(ConnectorName name, String version, List<String> dataStoreRefs,
List<PropertyType> requiredProperties, List<PropertyType> optionalProperties,
List<String> supportedOperations) {
this.name = name;
this.version = version;
List<String> supportedOperations) throws ManifestException {

if(name.getName().isEmpty()){
throw new ManifestException(new ExecutionException("Tag name cannot be empty"));
} else {
this.name = name;
}

if(version.isEmpty()){
throw new ManifestException(new ExecutionException("Tag version cannot be empty"));
} else {
this.version = version;
}

this.dataStoreRefs = ManifestHelper.convertManifestDataStoreNamesToMetadataDataStoreNames(dataStoreRefs);
if(this.dataStoreRefs == null){
this.dataStoreRefs = new HashSet<>();
}

if (requiredProperties != null) {
this.requiredProperties = ManifestHelper.convertManifestPropertiesToMetadataProperties(requiredProperties);
} else {
this.requiredProperties = null;
this.requiredProperties = new HashSet<>();
}

if (optionalProperties != null) {
this.optionalProperties = ManifestHelper.convertManifestPropertiesToMetadataProperties(optionalProperties);
} else {
this.optionalProperties = null;
this.optionalProperties = new HashSet<>();
}

this.supportedOperations = convertManifestOperationsToMetadataOperations(supportedOperations);
this.connectorStatus = ConnectorStatus.OFFLINE;
if(supportedOperations != null){
this.supportedOperations = convertManifestOperationsToMetadataOperations(supportedOperations);
} else {
this.supportedOperations = new HashSet<>();
}

this.connectorStatus = ConnectorStatus.OFFLINE;
}

/**
Expand Down Expand Up @@ -376,21 +414,33 @@ public void setSupportedOperations(Set<Operations> supportedOperations) {
*
* @param supportedOperations A list of supported operations.
*/
public void setSupportedOperations(List<String> supportedOperations) {
public void setSupportedOperations(List<String> supportedOperations) throws ManifestException {
this.supportedOperations = convertManifestOperationsToMetadataOperations(supportedOperations);
}

public boolean isManifestAdded() {
return manifestAdded;
}

public void setManifestAdded(boolean manifestAdded) {
this.manifestAdded = manifestAdded;
}

/**
* Convert a list of supported operations into a set of {@link com.stratio.crossdata.common.metadata.Operations}.
*
* @param supportedOperations The list of supported operations.
* @return A set of {@link com.stratio.crossdata.common.metadata.Operations}.
*/
private Set<Operations> convertManifestOperationsToMetadataOperations(
List<String> supportedOperations) {
List<String> supportedOperations) throws ManifestException {
Set<Operations> operations = new HashSet<>();
for (String supportedOperation : supportedOperations) {
operations.add(Operations.valueOf(supportedOperation.toUpperCase()));
try {
for (String supportedOperation: supportedOperations) {
operations.add(Operations.valueOf(supportedOperation.toUpperCase()));
}
} catch (IllegalArgumentException ex) {
throw new ManifestException(ex);
}
return operations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
package com.stratio.crossdata.common.metadata;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.stratio.crossdata.common.manifest.ManifestHelper;
import com.stratio.crossdata.common.manifest.PropertyType;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.DataStoreName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.ManifestException;
import com.stratio.crossdata.common.manifest.ManifestHelper;
import com.stratio.crossdata.common.manifest.PropertyType;

public class DataStoreMetadata implements IMetadata {
private final DataStoreName name;
private final String version;
private final Set<PropertyType> requiredProperties;
private final Set<PropertyType> othersProperties;
private final Set<String> behaviors;
private DataStoreName name;
private String version;
private Set<PropertyType> requiredProperties;
private Set<PropertyType> othersProperties;
private Set<String> behaviors;
private Map<ClusterName, ClusterAttachedMetadata> clusterAttachedRefs;

public DataStoreMetadata(DataStoreName name, String version, Set<PropertyType> requiredProperties,
Expand All @@ -47,24 +50,38 @@ public DataStoreMetadata(DataStoreName name, String version, Set<PropertyType> r
}

public DataStoreMetadata(DataStoreName name, String version, List<PropertyType> requiredProperties,
List<PropertyType> othersProperties, List<String> behaviors) {
this.name = name;
this.version = version;
List<PropertyType> othersProperties, List<String> behaviors) throws ManifestException {

if(name.getName().isEmpty()){
throw new ManifestException(new ExecutionException("Tag name cannot be empty"));
} else {
this.name = name;
}

if(version.isEmpty()){
throw new ManifestException(new ExecutionException("Tag version cannot be empty"));
} else {
this.version = version;
}

if(requiredProperties != null){
this.requiredProperties = ManifestHelper.convertManifestPropertiesToMetadataProperties(requiredProperties);
} else {
this.requiredProperties = null;
this.requiredProperties = new HashSet<>();
}

if(othersProperties != null){
this.othersProperties = ManifestHelper.convertManifestPropertiesToMetadataProperties(othersProperties);
} else {
this.othersProperties = null;
this.othersProperties = new HashSet<>();
}

if(behaviors != null){
this.behaviors = ManifestHelper.convertManifestBehaviorsToMetadataBehaviors(behaviors);
} else {
this.behaviors = null;
this.behaviors = new HashSet<>();
}

this.clusterAttachedRefs = new HashMap<>();
}

Expand Down
Loading

0 comments on commit 69673f1

Please sign in to comment.