org.gcube.couchbase
Class CouchBaseNode

java.lang.Object
  extended by org.gcube.couchbase.CouchBaseNode
All Implemented Interfaces:
Serializable

public class CouchBaseNode
extends Object
implements Serializable

Author:
Alex Antoniadis
See Also:
Serialized Form

Constructor Summary
CouchBaseNode(String clusterName, Integer replicas, Integer ramQuota, String scope)
           
CouchBaseNode(String nodeIP, String nodePort, String clusterName, Integer replicas, Integer ramQuota, String scope)
           
CouchBaseNode(String nodeIP, String nodePort, String username, String password, String clusterName, Integer replicas, Integer ramQuota, String scope)
           
 
Method Summary
 void addIndexTypes(Map<String,String> keysValues)
          Given at map of elements it adds the keys of that hold the DataType of each field and then it creates the indexes for each field
 boolean checkIfBucketExists()
          Checks if the bucket that is defined for the client exists
 void clear()
          Recreates the bucket
 void commitMetaIndexToDatabase()
          Saves the current state of meta index in the database and overrides the previous contents
 void connectTo(String host, String port)
          Initializes a client for the server located at host:port
 void createCluster(boolean forceCreate)
          Creates a cluster by creating a node and adding a node
 void delete()
          Deletes the bucket
 Boolean deleteCollection(String collectionID)
          Deletes all the documents of the given collection
 void deleteDocuments(List<String> docIDs)
          Deletes all the documents with keys given in docIDs param
 void destroy()
          Deletes the bucket and then shutdowns
 boolean feedLocator(String locator)
          Feeds the index with values taken from a specific locator.
 String getBucketName()
           
 String getDesignDocName()
           
 Map<String,CouchBaseDataTypesHelper.DataType> getKeys()
           
 MetaIndex getMetaIndex()
           
 org.gcube.indexmanagement.resourceregistry.RRadaptor getRradaptor()
           
 String getScope()
           
 void joinCluster(Map<String,String> knownHosts)
           
 void joinCluster(String knownHostIP, String knownHostPort)
          Joins a cluster of a known server
 void loadKeysFromMetaIndex()
          Loads the keys from the metaIndex
 void loadMetaFromDatabase()
          Loads the meta index from the database and discards current changes
 String query(String queryString)
          Executes the queryString and returns the answers at a specific locator.
 void setIndexType(Map<String,String> keysValues)
          Given at map of elements it creates the keys of that hold the DataType of each field and then it creates the indexes for each field
 void setMetaIndex(MetaIndex metaIndex)
           
 void shutdown()
          Shuts down the node and leaves the cluster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CouchBaseNode

public CouchBaseNode(String clusterName,
                     Integer replicas,
                     Integer ramQuota,
                     String scope)

CouchBaseNode

public CouchBaseNode(String nodeIP,
                     String nodePort,
                     String username,
                     String password,
                     String clusterName,
                     Integer replicas,
                     Integer ramQuota,
                     String scope)

CouchBaseNode

public CouchBaseNode(String nodeIP,
                     String nodePort,
                     String clusterName,
                     Integer replicas,
                     Integer ramQuota,
                     String scope)
Method Detail

getMetaIndex

public MetaIndex getMetaIndex()

setMetaIndex

public void setMetaIndex(MetaIndex metaIndex)

getKeys

public Map<String,CouchBaseDataTypesHelper.DataType> getKeys()

getRradaptor

public org.gcube.indexmanagement.resourceregistry.RRadaptor getRradaptor()

getDesignDocName

public String getDesignDocName()

getBucketName

public String getBucketName()

getScope

public String getScope()

checkIfBucketExists

public boolean checkIfBucketExists()
Checks if the bucket that is defined for the client exists

Returns:
true if bucket exists, false otherwise

createCluster

public void createCluster(boolean forceCreate)
                   throws Exception
Creates a cluster by creating a node and adding a node

Parameters:
forceCreate -
Throws:
Exception

connectTo

public void connectTo(String host,
                      String port)
               throws IOException
Initializes a client for the server located at host:port

Parameters:
host -
port -
Throws:
IOException

joinCluster

public void joinCluster(String knownHostIP,
                        String knownHostPort)
                 throws Exception
Joins a cluster of a known server

Parameters:
knownHostIP -
knownHostPort -
Throws:
Exception

joinCluster

public void joinCluster(Map<String,String> knownHosts)
                 throws Exception
Throws:
Exception

shutdown

public void shutdown()
              throws Exception
Shuts down the node and leaves the cluster

Throws:
Exception

destroy

public void destroy()
             throws Exception
Deletes the bucket and then shutdowns

Throws:
Exception

delete

public void delete()
            throws Exception
Deletes the bucket

Throws:
Exception

clear

public void clear()
           throws Exception
Recreates the bucket

Throws:
Exception

loadKeysFromMetaIndex

public void loadKeysFromMetaIndex()
Loads the keys from the metaIndex


setIndexType

public void setIndexType(Map<String,String> keysValues)
Given at map of elements it creates the keys of that hold the DataType of each field and then it creates the indexes for each field

Parameters:
keysValues -

addIndexTypes

public void addIndexTypes(Map<String,String> keysValues)
Given at map of elements it adds the keys of that hold the DataType of each field and then it creates the indexes for each field

Parameters:
keysValues -

query

public String query(String queryString)
Executes the queryString and returns the answers at a specific locator. The locator will be returned before all the answers are produced.

Parameters:
queryString -
Returns:
gRS2 locator of the answers

feedLocator

public boolean feedLocator(String locator)
                    throws gr.uoa.di.madgik.grs.reader.GRS2ReaderException,
                           URISyntaxException
Feeds the index with values taken from a specific locator. The locator produces gRS2 GenericRecords that have 1 field which is the actual Rowset that will be parsed. See ForwardIndexDocument for the parsing and the format that is expected.

Parameters:
locator -
Returns:
true if feeding succeed, false otherwise
Throws:
gr.uoa.di.madgik.grs.reader.GRS2ReaderException
URISyntaxException

deleteDocuments

public void deleteDocuments(List<String> docIDs)
Deletes all the documents with keys given in docIDs param

Parameters:
docIDs -

deleteCollection

public Boolean deleteCollection(String collectionID)
Deletes all the documents of the given collection

Parameters:
collectionID -

loadMetaFromDatabase

public void loadMetaFromDatabase()
Loads the meta index from the database and discards current changes


commitMetaIndexToDatabase

public void commitMetaIndexToDatabase()
Saves the current state of meta index in the database and overrides the previous contents



Copyright © 2013. All Rights Reserved.