Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Copyright 2014 The Johns Hopkins University Applied Physics Laboratory
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package edu.jhuapl.tinkerpop;
 
 import java.io.File;
 import java.util.List;
 import java.util.Map;
 
 import  org.apache.hadoop.io.Text;
 
 
 public class AccumuloGraphConfiguration  implements	Serializable {
 
 	
 	
 	private Configuration conf


The fully-qualified class name of the class that implements the TinkerPop Graph interface. This is used in a configuration object to tell the GraphFactory which type to instantiate.
 
 	public static final String ACCUMULO_GRAPH_CLASSNAME = AccumuloGraph.class
 
 	private static final long serialVersionUID = 7024072260167873696L;

An enumeration used by AccumuloGraphConfiguration.instanceType(InstanceType) to specify the backing Accumulo instance type. See the Accumulo Users' Guide for more information on the differnent types of develoment clients.
 
 	public static enum InstanceType {
 		Distributed, Mini, Mock
 	};
 
 	public static final String GRAPH_CLASS = "blueprints.graph";
 	public static final String ZK_HOSTS = "blueprints.accumulo.zkhosts";
 	public static final String INSTANCE = "blueprints.accumulo.instance";
 	public static final String INSTANCE_TYPE = "blueprints.accumulo.instance.type";
 	public static final String USER = "blueprints.accumulo.user";
 	public static final String PASSWORD = "blueprints.accumulo.password";
 	public static final String GRAPH_NAME = "blueprints.accumulo.name";
 	public static final String MAX_WRITE_LATENCY = "blueprints.accumulo.write.max.latency";
 	public static final String MAX_WRITE_MEMORY = "blueprints.accumulo.write.max.memory";
 	public static final String MAX_WRITE_THREADS = "blueprints.accumulo.write.max.threads";
 	public static final String MAX_WRITE_TIMEOUT = "blueprints.accumulo.write.timeout";
 	public static final String QUERY_THREADS = "blueprints.accumulo.read.queryThreads";
 	public static final String AUTHORIZATIONS = "blueprints.accumulo.authorizations";
 	public static final String AUTO_FLUSH = "blueprints.accumulo.auto.flush";
 	public static final String CREATE = "blueprints.accumulo.create";
 	public static final String SPLITS = "blueprints.accumulo.splits";
 	public static final String COLVIS = "blueprints.accumulo.columnVisibility";
 	public static final String SKIP_CHECKS = "blueprints.accumulo.skipExistenceChecks";
 	public static final String LRU_MAX_CAP = "blueprints.accumulo.lruMaximumCapacity";
 	public static final String PRELOAD_PROPERTIES = "blueprints.accumulo.property.preload";
 	public static final String EDGE_CACHE_TIMEOUT = "blueprints.accumulo.edgeCacheTimeout";
	public static final String PROPERTY_CACHE_TIMEOUT = "blueprints.accumulo.propertyCacheTimeout";
	public static final String VERTEX_CACHE_TIMEOUT = "blueprints.accumulo.vertexCacheTimeout";
	public static final String PRELOAD_EDGES = "blueprints.accumulo.edge.preload";

Backing store that maintains configuration values.
	private Map<StringObjectvalues;
	private transient ColumnVisibility cachedColVis = null;
	private transient Authorizations cachedAuths = null;
	private transient Boolean cachedAutoFlush = null;
	private transient Boolean cachedSkipChecks = null;
Temp directory used by getInstance when a Mini InstanceType is used.
		 = new HashMap<StringObject>();
		// set some defaults
		setMaxWriteLatency(60000L).setMaxWriteMemory(1024L * 1024 * 20)
				.autoFlush(true).create(false)
	}
		Iterator<Stringkeys = config.getKeys();
		while (keys.hasNext()) {
			String key = keys.next();
			.addProperty(key.replace("..""."), config.getProperty(key));
		}
	}
	public AccumuloGraphConfiguration create(boolean create) {
		return this;
	}
		return ;
	}
		.setProperty(zookeeperHosts);
		return this;
	}
		return this;
	}
		return this;
	}

The TinkerPop API defines certain operations should fail if a Vertex or Edge already exists or does not exist. For instance a call to getVertex() must first check if the vertex exists and, if not, return null. Likewise a call to addVertex() must first check if the vertex already exists and if so, throw and exception.

However since the AccumuloGraph does not assume (or attempt to maintain) the entire graph in RAM, these checks require a complete round-trip to the Accumulo instance to determine existence.

In some instances, the user may decide the existence checks are not needed and would rather not incur the round-trip costs. By setting this flag to true, the AccumuloGraph will not perform existence checks. A request to getVertex() will always return a Vertex instance. It is only when requesting data from that instance the AccumuloGraph will reach out to the Accumulo instance to determine if the Vertex actually exists.

In this case it is up to the user's code to ensure that requests for vertices are valid, requests to create new vertices are unique, etc.

Note that multiple requests to create the same node does not actually break the AccumuloGraph. The "existence" key/value pair identifying that ID as a Vertex in the vertex table will simply be repeated. The repeated key/value pair will eventually be collapsed back to a single pair (on the next compaction of the Accumulo graph). The trade-off here is additional I/O sending (potentially) duplicate create messages when nodes are repeated versus requiring a round-trip on every node create. In cases where repeated nodes are infrequent, it may be more efficient to simply (re-)create the Vertex rather than find the node in the graph.

That is, with skipExistenceChecks set to false:

 Vertex src = graph.addVertex(srcID);
 Vertex dest = graph.addVertex(destID);
 graph.addEdge(null, src, dest, "myEdge");
 
may be faster than:
 Vertex src = graph.getVertex(srcID);
 if (src == null) {
  src = graph.addVertex(srcId);
 }
 Vertex dest = graph.getVertex(destID);
 if (dest == null) {
  dest = graph.addVertex(destID);
 }
 graph.addEdge(null, src, dest, "myEdge");
 
if you are creating many edges where source and destination edges are infrequently repeated.

Similarly, in instances where the application can guarantee that source and destinations vertices for a given new edge have already been added to the Graph, skipping the existence checks for the source and destination vertices and utilizing getVertex() directly can speed the processing.

This flag defaults to false (checks will be made).

Parameters:
skip
Returns:
		return this;
	}

Sets the number of milliseconds since retrieval that a property value will be maintained in a RAM cache before that value is expired. If this value is unset or set to 0 (or a negative number) no caching will be performed.

A round-trip to Accumulo to retrieve a property value is an expensive operation. Setting this value to a positive number allows the AccumuloGraph to cache retrieved values and use those values (without re-consulting the backing Accumulo store) for the specified time. In situations where the graph is changing slowly and/or properties are revisited frequently, this can achieve a significant reduction in latency at the expense of consistency.

The default is unset (no caching).

Parameters:
millis the maximum number of milliseconds properties can be held in RAM
Returns:
		if (millis <= 0) {
else {
		}
		return this;
	}

Sets the number of milliseconds since retrieval that a Vertex instance will be maintained in a RAM cache before that value is expired. If this value is unset or set to 0 (or a negative number) no caching will be performed.

A round-trip to Accumulo to retrieve a Vertex is an expensive operation. Setting this value to a positive number allows the AccumuloGraph to cache retrieved Vertices and use those references (without re-consulting the backing Accumulo store) for the specified time. In situations where the graph is changing slowly and/or Vertices are revisited frequently, this can achieve a significant reduction in latency at the expense of consistency.

The default is unset (no caching).

Parameters:
millis the maximum number of milliseconds a Vertex should be held in RAM
Returns:
		if (millis <= 0) {
else {
		}
		return this;
	}

Sets the number of milliseconds since retrieval that an Edge instance will be maintained in a RAM cache before that value is expired. If this value is unset or set to 0 (or a negative number) no caching will be performed.

A round-trip to Accumulo to retrieve an Edge is an expensive operation. Setting this value to a positive number allows the AccumuloGraph to cache retrieved Edges and use those references (without re-consulting the backing Accumulo store) for the specified time. In situations where the graph is changing slowly and/or Edges are revisited frequently, this can achieve a significant reduction in latency at the expense of consistency.

The default is unset (no caching).

Parameters:
millis the maximum number of milliseconds an Edge should be held in RAM
Returns:
		if (millis <= 0) {
else {
		}
		return this;
	}

The number of query threads to use when accessing the backing Accumulo store. This value must be greater than or equal to one or an IllegalArgumentException will be thrown.

Parameters:
threads
Returns:
		if (threads < 1) {
					"You must provide at least 1 query thread.");
		}
		return this;
	}
		return this;
	}
		return this;
	}

The Graph can utilize an least-recently used (LRU) cache to avoid round-trip checks to Accumulo at the cost of consistency. Set this value to the maximum number of vertices or edges to be cached. A negative number means do not cache any values. TODO this probably should be a time-based cache eventually.

Parameters:
maxSize
Returns:
		return this;
	}

A space-separated, ordered list of splits to be applied to the backing Accumulo-table. Only applied if the graph does not already exist and the config create(boolean) is set to true.

Parameters:
splits
Returns:
		if (splits == null || splits.trim().isEmpty()) {
			return this;
		}
		return setSplits(splits.trim().split(" "));
	}
		.setProperty(splits != null ? Arrays.asList(splits) : null);
		return this;
	}
	public AccumuloGraphConfiguration setPassword(byte[] password) {
		.setProperty(new String(password));
		return this;
	}
		return this;
	}

Used by JUnit Tests to set the miniClusterTempDirectory. If not set in advance of a test, getConnector will use a Java Temporary Folder which will not be deleted afterwards.

Parameters:
miniClusterTempDir
	public void setMiniClusterTempDir(String miniClusterTempDir) {
	    this. = miniClusterTempDir;
	}


A flag if the AccumuloGraph should immediately flush each update to the backing AccumuloStore (true) or not (false). The TinkerPop API expects immediate consistency requiring each individual update to be immediately flushed to Accumulo. However, this incurs significant overhead. For applications at scale that do not require immediate consistency, this flag allows the user to lessen the TinkerPop restriction.

To support the expected TinkerPop behavior, the default value is true. However, it is strongly recommended that this option be disabled.

Parameters:
autoFlush
Returns:
	public AccumuloGraphConfiguration autoFlush(boolean autoFlush) {
		return this;
	}
		return this;
	}
		if (latency < 0) {
					"Maximum write latency must be a postive number, "
"or '0' for no maximum.");
		}
		return this;
	}
		if (timeout < 0) {
					"Maximum write timeout must be a postive number, "
"or '0' for no maximum.");
		}
		return this;
	}

A trip to the backing-Accumulo store to obtain data is a relatively expensive operation. In cases where the end-user knows there are certain sets of properties that will always/very likely be obtained, it may be more efficient to grab all of those properties at once as the element existence is confirmed. In other cases (e.g., rarely used or very large properties) it may be more efficient to wait to obtain the data until the program determines the property is in fact needed.

Deferred property loading is the default. By setting this configuration value, any keys in the provided property list will be automatically loaded in bulk when it makes sense (i.e., when the system has to make a trip out to Accumulo anyway). Other proerties not in the list will continue to be lazily and individually loaded.

In order to set this value, you must first define a postive property cache timeout value (propertyCacheTimeout(int); it does not make sense to pre-load data if you do not allow caching.

Parameters:
propertyKeys
Returns:
		if (propertyKeys == null) {
			throw new NullPointerException("Property keys cannot be null.");
		}
		return this;
	}
		if (edgeLabels == null) {
			throw new NullPointerException("Edge labels cannot be null.");
		}
		if (timeout == null) {
			throw new IllegalArgumentException("You cannot preload edges "
"without first setting #edgeCacheTimeout(int millis) "
"to a positive value.");
		}
		return this;
	}
		if (mem <= 0) {
					"Maximum write memory must be a postive number.");
		}
		return this;
	}
		if (threads < 1) {
					"Maximum write threads must be a postive number.");
		}
		return this;
	}
		byte[] data = auths.getAuthorizationsArray();
		return this;
	}
	public boolean isCreate() {
	}
		return InstanceType.valueOf(.getString());
	}
		if ( == null) {
			if (auths != null) {
			}
		}
		return ;
	}
	public String getUser() {
	}
	public ByteBuffer getPassword() {
		return ByteBuffer.wrap(.getString().getBytes());
	}
	public String getInstance() {
	}
	}
	public boolean isAutoFlush() {
		if ( == null) {
		}
	}
	}
	}
	}
	public boolean skipExistenceChecks() {
		if ( == null) {
		}
	}
	public long getMaxWriteMemory() {
	}
	public long getMaxWriteTimeout() {
	}
		return new BatchWriterConfig()
	}
	public SortedSet<Text> getSplits() {
		if ((val == null) || (val.length == 0)) {
			return null;
		}
		SortedSet<Text> splits = new TreeSet<Text>();
		for (String s : val) {
			splits.add(new Text(s));
		}
		return splits;
	}
	public long getMaxWriteLatency() {
	}
	public int getMaxWriteThreads() {
	}
	public String getName() {
	}
	public boolean useLruCache() {
		return getLruMaxCapacity() > 0;
	}
	public int getLruMaxCapacity() {
		return .getInt(, -1);
	}
		if ( == null) {
		}
		return ;
	}
		Instance inst = null;
		switch (getInstanceType()) {
			break;
		case :
		    File dir = null;
		    if( == null) {
	            dir = createTempDir();
	            dir.deleteOnExit();
		    } else {
		        // already set by setMiniClusterTempDir(), It should be cleaned up outside of this class.
		        dir = new File();
		    }
		     = new MiniAccumuloCluster(dir"" );  //conf.getString(PASSWORD)
		    try {
		        .start();
		    } catch (Exception ex ) {
		        ex.printStackTrace();
		        ..println("");
		    }
			throw new UnsupportedOperationException("TODO");
		case :
			inst = new MockInstance(getInstance());
			break;
		default:
			throw new RuntimeException("Unexpected instance type: " + inst);
		}
		return c;
	}
		}
		return null;
	}
	public String[] getPreloadedEdges() {
		}
		return null;
	}
	public int getQueryThreads() {
	}
	public boolean containsKey(String key) {
		return .containsKey(key);
	}
	public boolean isEmpty() {
		return .isEmpty();
	}
	public String getVertexTable() {
		return getName() + "_vertex";
	}
	public String getEdgeTable() {
		return getName() + "_edge";
	}
		return getName() + "_vertex_index";
	}
		return getName() + "_edge_index";
	}
		return getName() + "_meta";
	}
		if ( == null) {
		}
		return ;
	}
	protected void addPropertyDirect(String keyObject value) {
		if ((key.equals()) || (key.equals()) || (key.equals())) {
			List<Stringlist = (List<String>) .get(key);
			if (list == null) {
				list = new ArrayList<String>();
				.put(keylist);
			}
			list.add(value.toString());
else {
			.put(keyvalue);
		}
	}
	public void validate() {
		switch (getInstanceType()) {
			// no break intentional
		case :
					true);
			// no break intentional
		case :
			break;
		default:
			throw new RuntimeException("Unexpected instance type: "
		}
		if (timeout < 0 && .getProperty() != null) {
					"You cannot preload properties "
"without first setting #propertyCacheTimeout(int millis) "
"to a positive value.");
		}
	}
	private void checkPropertyValue(String propString valboolean canBeEmpty) {
		if (val == null) {
			throw new AccumuloGraphException(prop + " cannot be null.");
		}
		if ((!canBeEmpty) && (val.equals(""))) {
			throw new AccumuloGraphException(prop + " cannot be empty.");
		}
	}
		return getMetadataTable() + "KEY";
	}
		return getName() + "_vertex_index_key";
	}
		return getName() + "_edge_index_key";
	}

Creates a temporary directory. Under the java.io.tmpdir property location.

Returns:
    private File createTempDir() {
        final int ATTEMPTS=100;
        File parent = new File(System.getProperty("java.io.tmpdir"));
        String child = System.currentTimeMillis() + "-";
        for (int counter = 0; counter < ATTEMPTScounter++) {
          File tempDir = new File(parentchild + counter);
          if (tempDir.mkdir()) {
            return tempDir;
          }
        }
        throw new IllegalStateException("Failed to create directory, tried directories: "
          + child + "0 to " + child + (ATTEMPTS - 1) );
      }
New to GrepCode? Check out our FAQ X