You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gora.apache.org by dj...@apache.org on 2018/10/08 09:02:39 UTC
[04/11] gora git commit: Add mapping reading and initialization for
Ignite backend
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java b/gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java
index 2f5faf9..d52d10e 100644
--- a/gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java
+++ b/gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java
@@ -16,1005 +16,165 @@
*/
package org.apache.gora.ignite.store;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.MessageFormat;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
+import java.util.Locale;
import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.ignite.core.client.IgniteException;
-import org.apache.ignite.core.client.IgniteSecurityException;
-import org.apache.ignite.core.client.BatchWriter;
-import org.apache.ignite.core.client.BatchWriterConfig;
-import org.apache.ignite.core.client.Connector;
-import org.apache.ignite.core.client.IsolatedScanner;
-import org.apache.ignite.core.client.IteratorSetting;
-import org.apache.ignite.core.client.MutationsRejectedException;
-import org.apache.ignite.core.client.RowIterator;
-import org.apache.ignite.core.client.Scanner;
-import org.apache.ignite.core.client.TableDeletedException;
-import org.apache.ignite.core.client.TableExistsException;
-import org.apache.ignite.core.client.TableNotFoundException;
-import org.apache.ignite.core.client.TableOfflineException;
-import org.apache.ignite.core.client.ZooKeeperInstance;
-import org.apache.ignite.core.client.impl.ClientContext;
-import org.apache.ignite.core.client.impl.Tables;
-import org.apache.ignite.core.client.impl.TabletLocator;
-import org.apache.ignite.core.client.mock.MockConnector;
-import org.apache.ignite.core.client.mock.MockInstance;
-import org.apache.ignite.core.client.mock.impl.MockTabletLocator;
-import org.apache.ignite.core.client.security.tokens.AuthenticationToken;
-import org.apache.ignite.core.client.security.tokens.PasswordToken;
-import org.apache.ignite.core.conf.IgniteConfiguration;
-import org.apache.ignite.core.data.ByteSequence;
-import org.apache.ignite.core.data.Key;
-import org.apache.ignite.core.data.impl.KeyExtent;
-import org.apache.ignite.core.data.Mutation;
-import org.apache.ignite.core.data.Range;
-import org.apache.ignite.core.data.Value;
-import org.apache.ignite.core.iterators.SortedKeyIterator;
-import org.apache.ignite.core.iterators.user.TimestampFilter;
-import org.apache.ignite.core.master.state.tables.TableState;
-import org.apache.ignite.core.security.Authorizations;
-import org.apache.ignite.core.security.ColumnVisibility;
-import org.apache.ignite.core.client.impl.Credentials;
-import org.apache.ignite.core.util.Pair;
-import org.apache.ignite.core.util.UtilWaitThread;
-import org.apache.avro.Schema;
-import org.apache.avro.Schema.Field;
-import org.apache.avro.Schema.Type;
-import org.apache.avro.generic.GenericData;
-import org.apache.avro.io.BinaryDecoder;
-import org.apache.avro.io.Decoder;
-import org.apache.avro.io.DecoderFactory;
-import org.apache.avro.io.EncoderFactory;
-import org.apache.avro.specific.SpecificDatumReader;
-import org.apache.avro.specific.SpecificDatumWriter;
-import org.apache.avro.util.Utf8;
-import org.apache.gora.ignite.encoders.BinaryEncoder;
-import org.apache.gora.ignite.encoders.Encoder;
-import org.apache.gora.ignite.query.IgniteQuery;
-import org.apache.gora.ignite.query.IgniteResult;
-import org.apache.gora.persistency.impl.DirtyListWrapper;
-import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import java.util.logging.Level;
import org.apache.gora.persistency.impl.PersistentBase;
import org.apache.gora.query.PartitionQuery;
import org.apache.gora.query.Query;
import org.apache.gora.query.Result;
-import org.apache.gora.query.impl.PartitionQueryImpl;
-import org.apache.gora.store.DataStoreFactory;
import org.apache.gora.store.impl.DataStoreBase;
-import org.apache.gora.util.AvroUtils;
import org.apache.gora.util.GoraException;
-import org.apache.gora.util.IOUtils;
-import org.apache.hadoop.io.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/**
* Implementation of a Ignite data store to be used by gora.
*
- * @param <K>
- * class to be used for the key
- * @param <T>
- * class to be persisted within the store
+ * @param <K> class to be used for the key
+ * @param <T> class to be persisted within the store
*/
-public class IgniteStore<K,T extends PersistentBase> extends DataStoreBase<K,T> {
-
- protected static final String MOCK_PROPERTY = "ignite.mock";
- protected static final String INSTANCE_NAME_PROPERTY = "ignite.instance";
- protected static final String ZOOKEEPERS_NAME_PROPERTY = "ignite.zookeepers";
- protected static final String USERNAME_PROPERTY = "ignite.user";
- protected static final String PASSWORD_PROPERTY = "ignite.password";
- protected static final String DEFAULT_MAPPING_FILE = "gora-ignite-mapping.xml";
-
- private final static String UNKOWN = "Unknown type ";
-
- private Connector conn;
- private BatchWriter batchWriter;
- private IgniteMapping mapping;
- private Credentials credentials;
- private Encoder encoder;
+public class IgniteStore<K, T extends PersistentBase> extends DataStoreBase<K, T> {
public static final Logger LOG = LoggerFactory.getLogger(IgniteStore.class);
+ private static final String PARSE_MAPPING_FILE_KEY = "gora.ignite.mapping.file";
+ private static final String DEFAULT_MAPPING_FILE = "gora-ignite-mapping.xml";
+ private IgniteParameters igniteParameters;
+ private IgniteMapping igniteMapping;
+ private Connection connection;
- public Object fromBytes(Schema schema, byte[] data) throws IOException {
- Schema fromSchema = null;
- if (schema.getType() == Type.UNION) {
- try {
- Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
- int unionIndex = decoder.readIndex();
- List<Schema> possibleTypes = schema.getTypes();
- fromSchema = possibleTypes.get(unionIndex);
- Schema effectiveSchema = possibleTypes.get(unionIndex);
- if (effectiveSchema.getType() == Type.NULL) {
- decoder.readNull();
- return null;
- } else {
- data = decoder.readBytes(null).array();
- }
- } catch (IOException e) {
- LOG.error(e.getMessage());
- throw new GoraException("Error decoding union type: ", e);
- }
- } else {
- fromSchema = schema;
- }
- return fromBytes(encoder, fromSchema, data);
- }
-
- public static Object fromBytes(Encoder encoder, Schema schema, byte data[]) throws IOException {
- switch (schema.getType()) {
- case BOOLEAN:
- return encoder.decodeBoolean(data);
- case DOUBLE:
- return encoder.decodeDouble(data);
- case FLOAT:
- return encoder.decodeFloat(data);
- case INT:
- return encoder.decodeInt(data);
- case LONG:
- return encoder.decodeLong(data);
- case STRING:
- return new Utf8(data);
- case BYTES:
- return ByteBuffer.wrap(data);
- case ENUM:
- return AvroUtils.getEnumValue(schema, encoder.decodeInt(data));
- case ARRAY:
- break;
- case FIXED:
- break;
- case MAP:
- break;
- case NULL:
- break;
- case RECORD:
- break;
- case UNION:
- break;
- default:
- break;
- }
- throw new IllegalArgumentException(UNKOWN + schema.getType());
-
- }
-
- private static byte[] getBytes(Text text) {
- byte[] bytes = text.getBytes();
- if (bytes.length != text.getLength()) {
- bytes = new byte[text.getLength()];
- System.arraycopy(text.getBytes(), 0, bytes, 0, bytes.length);
- }
- return bytes;
- }
-
- public K fromBytes(Class<K> clazz, byte[] val) {
- return fromBytes(encoder, clazz, val);
- }
+ @Override
+ public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
- @SuppressWarnings("unchecked")
- public static <K> K fromBytes(Encoder encoder, Class<K> clazz, byte[] val) {
try {
- if (clazz.equals(Byte.TYPE) || clazz.equals(Byte.class)) {
- return (K) Byte.valueOf(encoder.decodeByte(val));
- } else if (clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class)) {
- return (K) Boolean.valueOf(encoder.decodeBoolean(val));
- } else if (clazz.equals(Short.TYPE) || clazz.equals(Short.class)) {
- return (K) Short.valueOf(encoder.decodeShort(val));
- } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
- return (K) Integer.valueOf(encoder.decodeInt(val));
- } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
- return (K) Long.valueOf(encoder.decodeLong(val));
- } else if (clazz.equals(Float.TYPE) || clazz.equals(Float.class)) {
- return (K) Float.valueOf(encoder.decodeFloat(val));
- } else if (clazz.equals(Double.TYPE) || clazz.equals(Double.class)) {
- return (K) Double.valueOf(encoder.decodeDouble(val));
- } else if (clazz.equals(String.class)) {
- return (K) new String(val, "UTF-8");
- } else if (clazz.equals(Utf8.class)) {
- return (K) new Utf8(val);
- }
-
- throw new IllegalArgumentException(UNKOWN + clazz.getName());
- } catch (IOException ioe) {
- LOG.error(ioe.getMessage());
- throw new RuntimeException(ioe);
+ super.initialize(keyClass, persistentClass, properties);
+ IgniteMappingBuilder builder = new IgniteMappingBuilder(this);
+ builder.readMappingFile(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE));
+ igniteMapping = builder.getIgniteMapping();
+ igniteParameters = IgniteParameters.load(properties, conf);
+ connection = acquiereConnection();
+ LOG.info("Ignite store was successfully initialized");
+ } catch (ClassNotFoundException | SQLException ex) {
+ LOG.error("Error while initializing Ignite store", ex);
+ throw new GoraException(ex);
}
}
- private static byte[] copyIfNeeded(byte b[], int offset, int len) {
- if (len != b.length || offset != 0) {
- byte[] copy = new byte[len];
- System.arraycopy(b, offset, copy, 0, copy.length);
- b = copy;
+ private Connection acquiereConnection() throws ClassNotFoundException, SQLException {
+ Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
+ StringBuilder urlBuilder = new StringBuilder();
+ urlBuilder.append("jdbc:ignite:thin://");
+ urlBuilder.append(igniteParameters.getHost());
+ if (igniteParameters.getPort() != null) {
+ urlBuilder.append(":" + igniteParameters.getPort());
}
- return b;
- }
-
- public byte[] toBytes(Schema toSchema, Object o) {
- if (toSchema != null && toSchema.getType() == Type.UNION) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- org.apache.avro.io.BinaryEncoder avroEncoder = EncoderFactory.get().binaryEncoder(baos, null);
- int unionIndex = 0;
- try {
- if (o == null) {
- unionIndex = firstNullSchemaTypeIndex(toSchema);
- avroEncoder.writeIndex(unionIndex);
- avroEncoder.writeNull();
- } else {
- unionIndex = firstNotNullSchemaTypeIndex(toSchema);
- avroEncoder.writeIndex(unionIndex);
- avroEncoder.writeBytes(toBytes(o));
- }
- avroEncoder.flush();
- return baos.toByteArray();
- } catch (IOException e) {
- LOG.error(e.getMessage());
- return toBytes(o);
- }
- } else {
- return toBytes(o);
+ if (igniteParameters.getSchema() != null) {
+ urlBuilder.append("/" + igniteParameters.getSchema());
}
- }
-
- private int firstNullSchemaTypeIndex(Schema toSchema) {
- List<Schema> possibleTypes = toSchema.getTypes();
- int unionIndex = 0;
- for (int i = 0; i < possibleTypes.size(); i++ ) {
- Type pType = possibleTypes.get(i).getType();
- if (pType == Type.NULL) { // FIXME HUGE kludge to pass tests
- unionIndex = i; break;
- }
+ if (igniteParameters.getUser() != null) {
+ urlBuilder.append(";" + igniteParameters.getUser());
}
- return unionIndex;
- }
-
- private int firstNotNullSchemaTypeIndex(Schema toSchema) {
- List<Schema> possibleTypes = toSchema.getTypes();
- int unionIndex = 0;
- for (int i = 0; i < possibleTypes.size(); i++ ) {
- Type pType = possibleTypes.get(i).getType();
- if (pType != Type.NULL) { // FIXME HUGE kludge to pass tests
- unionIndex = i; break;
- }
+ if (igniteParameters.getPassword() != null) {
+ urlBuilder.append(";" + igniteParameters.getPassword());
}
- return unionIndex;
- }
-
- public byte[] toBytes(Object o) {
- return toBytes(encoder, o);
- }
-
- public static byte[] toBytes(Encoder encoder, Object o) {
-
- try {
- if (o instanceof String) {
- return ((String) o).getBytes("UTF-8");
- } else if (o instanceof Utf8) {
- return copyIfNeeded(((Utf8) o).getBytes(), 0, ((Utf8) o).getByteLength());
- } else if (o instanceof ByteBuffer) {
- return copyIfNeeded(((ByteBuffer) o).array(), ((ByteBuffer) o).arrayOffset() + ((ByteBuffer) o).position(), ((ByteBuffer) o).remaining());
- } else if (o instanceof Long) {
- return encoder.encodeLong((Long) o);
- } else if (o instanceof Integer) {
- return encoder.encodeInt((Integer) o);
- } else if (o instanceof Short) {
- return encoder.encodeShort((Short) o);
- } else if (o instanceof Byte) {
- return encoder.encodeByte((Byte) o);
- } else if (o instanceof Boolean) {
- return encoder.encodeBoolean((Boolean) o);
- } else if (o instanceof Float) {
- return encoder.encodeFloat((Float) o);
- } else if (o instanceof Double) {
- return encoder.encodeDouble((Double) o);
- } else if (o instanceof Enum) {
- return encoder.encodeInt(((Enum<?>) o).ordinal());
- }
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
+ if (igniteParameters.getAdditionalConfigurations() != null) {
+ urlBuilder.append(igniteParameters.getAdditionalConfigurations());
}
-
- throw new IllegalArgumentException(UNKOWN + o.getClass().getName());
- }
-
- private BatchWriter getBatchWriter() throws IOException {
- if (batchWriter == null)
- try {
- BatchWriterConfig batchWriterConfig = new BatchWriterConfig();
- batchWriterConfig.setMaxMemory(10000000);
- batchWriterConfig.setMaxLatency(60000L, TimeUnit.MILLISECONDS);
- batchWriterConfig.setMaxWriteThreads(4);
- batchWriter = conn.createBatchWriter(mapping.tableName, batchWriterConfig);
- } catch (TableNotFoundException e) {
- throw new IOException(e);
- }
- return batchWriter;
+ Connection conn = DriverManager.getConnection(urlBuilder.toString());
+ return conn;
}
- /**
- * Initialize the data store by reading the credentials, setting the client's properties up and
- * reading the mapping file. Initialize is called when then the call to
- * {@link org.apache.gora.store.DataStoreFactory#createDataStore} is made.
- *
- * @param keyClass
- * @param persistentClass
- * @param properties
- */
@Override
- public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
- super.initialize(keyClass, persistentClass, properties);
-
- try {
-
- String mock = DataStoreFactory.findProperty(properties, this, MOCK_PROPERTY, null);
- String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE);
- String user = DataStoreFactory.findProperty(properties, this, USERNAME_PROPERTY, null);
- String password = DataStoreFactory.findProperty(properties, this, PASSWORD_PROPERTY, null);
-
- mapping = readMapping(mappingFile);
-
- if (mapping.encoder == null || "".equals(mapping.encoder)) {
- encoder = new BinaryEncoder();
- } else {
- encoder = (Encoder) getClass().getClassLoader().loadClass(mapping.encoder).newInstance();
- }
-
- AuthenticationToken token = new PasswordToken(password);
- if (mock == null || !mock.equals("true")) {
- String instance = DataStoreFactory.findProperty(properties, this, INSTANCE_NAME_PROPERTY, null);
- String zookeepers = DataStoreFactory.findProperty(properties, this, ZOOKEEPERS_NAME_PROPERTY, null);
- conn = new ZooKeeperInstance(instance, zookeepers).getConnector(user, token);
- } else {
- conn = new MockInstance().getConnector(user, token);
- }
- credentials = new Credentials(user, token);
-
- if (autoCreateSchema && !schemaExists())
- createSchema();
-
- } catch (IOException | InstantiationException | IllegalAccessException |
- ClassNotFoundException | IgniteException | IgniteSecurityException e) {
- throw new GoraException(e);
- }
- }
-
- protected IgniteMapping readMapping(String filename) throws IOException {
- try {
-
- IgniteMapping mapping = new IgniteMapping();
-
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document dom = db.parse(getClass().getClassLoader().getResourceAsStream(filename));
-
- Element root = dom.getDocumentElement();
-
- NodeList nl = root.getElementsByTagName("class");
- for (int i = 0; i < nl.getLength(); i++) {
-
- Element classElement = (Element) nl.item(i);
- if (classElement.getAttribute("keyClass").equals(keyClass.getCanonicalName())
- && classElement.getAttribute("name").equals(persistentClass.getCanonicalName())) {
-
- mapping.tableName = getSchemaName(classElement.getAttribute("table"), persistentClass);
- mapping.encoder = classElement.getAttribute("encoder");
-
- NodeList fields = classElement.getElementsByTagName("field");
- for (int j = 0; j < fields.getLength(); j++) {
- Element fieldElement = (Element) fields.item(j);
-
- String name = fieldElement.getAttribute("name");
- String family = fieldElement.getAttribute("family");
- String qualifier = fieldElement.getAttribute("qualifier");
- if ("".equals(qualifier))
- qualifier = null;
-
- Pair<Text,Text> col = new Pair<>(new Text(family), qualifier == null ? null : new Text(qualifier));
- mapping.fieldMap.put(name, col);
- mapping.columnMap.put(col, name);
- }
- }
-
- }
-
- if (mapping.tableName == null) {
- throw new GoraException("Please define the ignite 'table' name mapping in " + filename + " for " + persistentClass.getCanonicalName());
- }
-
- nl = root.getElementsByTagName("table");
- for (int i = 0; i < nl.getLength(); i++) {
- Element tableElement = (Element) nl.item(i);
- if (tableElement.getAttribute("name").equals(mapping.tableName)) {
- NodeList configs = tableElement.getElementsByTagName("config");
- for (int j = 0; j < configs.getLength(); j++) {
- Element configElement = (Element) configs.item(j);
- String key = configElement.getAttribute("key");
- String val = configElement.getAttribute("value");
- mapping.tableConfig.put(key, val);
- }
- }
- }
-
- return mapping;
- } catch (Exception ex) {
- throw new IOException("Unable to read " + filename, ex);
- }
-
+ public String getSchemaName() {
+ return igniteMapping.getTableName();
}
@Override
- public String getSchemaName() {
- return mapping.tableName;
+ public String getSchemaName(final String mappingSchemaName,
+ final Class<?> persistentClass) {
+ return super.getSchemaName(mappingSchemaName, persistentClass);
}
@Override
public void createSchema() throws GoraException {
- try {
- conn.tableOperations().create(mapping.tableName);
- Set<Entry<String,String>> es = mapping.tableConfig.entrySet();
- for (Entry<String,String> entry : es) {
- conn.tableOperations().setProperty(mapping.tableName, entry.getKey(), entry.getValue());
- }
-
- } catch (TableExistsException e) {
- LOG.debug(e.getMessage(), e);
- // Assume this is not an error
- } catch (IgniteException | IgniteSecurityException e) {
- throw new GoraException(e);
- }
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void deleteSchema() throws GoraException {
- try {
- if (batchWriter != null)
- batchWriter.close();
- batchWriter = null;
- conn.tableOperations().delete(mapping.tableName);
- } catch (TableNotFoundException e) {
- // Ignore. Delete a non existant schema is a success
- } catch (IgniteException | IgniteSecurityException e) {
- throw new GoraException(e);
- }
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean schemaExists() throws GoraException {
- try {
- return conn.tableOperations().exists(mapping.tableName);
- } catch (Exception e) {
- throw new GoraException(e);
- }
- }
-
- public ByteSequence populate(Iterator<Entry<Key,Value>> iter, T persistent) throws IOException {
- ByteSequence row = null;
-
- Map<Utf8, Object> currentMap = null;
- List currentArray = null;
- Text currentFam = null;
- int currentPos = 0;
- Schema currentSchema = null;
- Field currentField = null;
-
- BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(new byte[0], null);
-
- while (iter.hasNext()) {
- Entry<Key,Value> entry = iter.next();
-
- if (row == null) {
- row = entry.getKey().getRowData();
- }
- byte[] val = entry.getValue().get();
-
- Field field = fieldMap.get(getFieldName(entry));
-
- if (currentMap != null) {
- if (currentFam.equals(entry.getKey().getColumnFamily())) {
- currentMap.put(new Utf8(entry.getKey().getColumnQualifierData().toArray()),
- fromBytes(currentSchema, entry.getValue().get()));
- continue;
- } else {
- persistent.put(currentPos, currentMap);
- currentMap = null;
- }
- } else if (currentArray != null) {
- if (currentFam.equals(entry.getKey().getColumnFamily())) {
- currentArray.add(fromBytes(currentSchema, entry.getValue().get()));
- continue;
- } else {
- persistent.put(currentPos, new GenericData.Array<T>(currentField.schema(), currentArray));
- currentArray = null;
- }
- }
-
- switch (field.schema().getType()) {
- case MAP: // first entry only. Next are handled above on the next loop
- currentMap = new DirtyMapWrapper<>(new HashMap<Utf8, Object>());
- currentPos = field.pos();
- currentFam = entry.getKey().getColumnFamily();
- currentSchema = field.schema().getValueType();
-
- currentMap.put(new Utf8(entry.getKey().getColumnQualifierData().toArray()),
- fromBytes(currentSchema, entry.getValue().get()));
- break;
- case ARRAY:
- currentArray = new DirtyListWrapper<>(new ArrayList<>());
- currentPos = field.pos();
- currentFam = entry.getKey().getColumnFamily();
- currentSchema = field.schema().getElementType();
- currentField = field;
-
- currentArray.add(fromBytes(currentSchema, entry.getValue().get()));
-
- break;
- case UNION:// default value of null acts like union with null
- Schema effectiveSchema = field.schema().getTypes()
- .get(firstNotNullSchemaTypeIndex(field.schema()));
- // map and array were coded without union index so need to be read the same way
- if (effectiveSchema.getType() == Type.ARRAY) {
- currentArray = new DirtyListWrapper<>(new ArrayList<>());
- currentPos = field.pos();
- currentFam = entry.getKey().getColumnFamily();
- currentSchema = field.schema().getElementType();
- currentField = field;
-
- currentArray.add(fromBytes(currentSchema, entry.getValue().get()));
- break;
- }
- else if (effectiveSchema.getType() == Type.MAP) {
- currentMap = new DirtyMapWrapper<>(new HashMap<Utf8, Object>());
- currentPos = field.pos();
- currentFam = entry.getKey().getColumnFamily();
- currentSchema = effectiveSchema.getValueType();
-
- currentMap.put(new Utf8(entry.getKey().getColumnQualifierData().toArray()),
- fromBytes(currentSchema, entry.getValue().get()));
- break;
- }
- // continue like a regular top-level union
- case RECORD:
- SpecificDatumReader<?> reader = new SpecificDatumReader<Schema>(field.schema());
- persistent.put(field.pos(), reader.read(null, DecoderFactory.get().binaryDecoder(val, decoder)));
- break;
- default:
- persistent.put(field.pos(), fromBytes(field.schema(), entry.getValue().get()));
- }
- }
-
- if (currentMap != null) {
- persistent.put(currentPos, currentMap);
- } else if (currentArray != null) {
- persistent.put(currentPos, new GenericData.Array<T>(currentField.schema(), currentArray));
- }
-
- persistent.clearDirty();
-
- return row;
- }
-
- /**
- * Retrieve field name from entry.
- * @param entry The Key-Value entry
- * @return String The field name
- */
- private String getFieldName(Entry<Key, Value> entry) {
- String fieldName = mapping.columnMap.get(new Pair<>(entry.getKey().getColumnFamily(),
- entry.getKey().getColumnQualifier()));
- if (fieldName == null) {
- fieldName = mapping.columnMap.get(new Pair<Text,Text>(entry.getKey().getColumnFamily(), null));
- }
- return fieldName;
- }
-
- private void setFetchColumns(Scanner scanner, String[] fields) {
- fields = getFieldsToQuery(fields);
- for (String field : fields) {
- Pair<Text,Text> col = mapping.fieldMap.get(field);
- if (col != null) {
- if (col.getSecond() == null) {
- scanner.fetchColumnFamily(col.getFirst());
- } else {
- scanner.fetchColumn(col.getFirst(), col.getSecond());
- }
+ boolean exists = false;
+ try (Statement stmt = connection.createStatement()) {
+ MessageFormat messageFormat = new MessageFormat("select * from {0} limit 0", Locale.getDefault());
+ ResultSet executeQuery = stmt.executeQuery(messageFormat.format(igniteMapping.getTableName()));
+ executeQuery.close();
+ exists = true;
+ } catch (SQLException ex) {
+ /**
+ * a 42000 error code is thrown by Ignite when a non-existent table
+ * queried. More details:
+ * https://apacheignite-sql.readme.io/docs/jdbc-error-codes
+ */
+ if (ex.getSQLState() != null && ex.getSQLState().equals("42000")) {
+ exists = false;
} else {
- LOG.error("Mapping not found for field: {}", field);
+ throw new GoraException(ex);
}
}
+ return exists;
}
@Override
public T get(K key, String[] fields) throws GoraException {
- try {
- // TODO make isolated scanner optional?
- Scanner scanner = new IsolatedScanner(conn.createScanner(mapping.tableName, Authorizations.EMPTY));
- Range rowRange = new Range(new Text(toBytes(key)));
-
- scanner.setRange(rowRange);
- setFetchColumns(scanner, fields);
-
- T persistent = newPersistent();
- ByteSequence row = populate(scanner.iterator(), persistent);
- if (row == null)
- return null;
- return persistent;
- } catch (Exception e) {
- throw new GoraException(e);
- }
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
- public void put(K key, T val) throws GoraException {
-
- try{
- Mutation m = new Mutation(new Text(toBytes(key)));
-
- Schema schema = val.getSchema();
- List<Field> fields = schema.getFields();
- int count = 0;
-
- for (int i = 0; i < fields.size(); i++) {
- if (!val.isDirty(i)) {
- continue;
- }
- Field field = fields.get(i);
-
- Object o = val.get(field.pos());
-
- Pair<Text,Text> col = mapping.fieldMap.get(field.name());
-
- if (col == null) {
- throw new GoraException("Please define the gora to ignite mapping for field " + field.name());
- }
-
- switch (field.schema().getType()) {
- case MAP:
- count = putMap(m, count, field.schema().getValueType(), o, col, field.name());
- break;
- case ARRAY:
- count = putArray(m, count, o, col, field.name());
- break;
- case UNION: // default value of null acts like union with null
- Schema effectiveSchema = field.schema().getTypes()
- .get(firstNotNullSchemaTypeIndex(field.schema()));
- // map and array need to compute qualifier
- if (effectiveSchema.getType() == Type.ARRAY) {
- count = putArray(m, count, o, col, field.name());
- break;
- }
- else if (effectiveSchema.getType() == Type.MAP) {
- count = putMap(m, count, effectiveSchema.getValueType(), o, col, field.name());
- break;
- }
- // continue like a regular top-level union
- case RECORD:
- final SpecificDatumWriter<Object> writer = new SpecificDatumWriter<>(field.schema());
- final byte[] byteData = IOUtils.serialize(writer,o);
- m.put(col.getFirst(), col.getSecond(), new Value(byteData));
- count++;
- break;
- default:
- m.put(col.getFirst(), col.getSecond(), new Value(toBytes(o)));
- count++;
- }
-
- }
-
- if (count > 0)
- try {
- getBatchWriter().addMutation(m);
- } catch (MutationsRejectedException e) {
- LOG.error(e.getMessage(), e);
- }
- } catch (GoraException e) {
- throw e;
- } catch (Exception e) {
- throw new GoraException(e);
- }
- }
-
- private int putMap(Mutation m, int count, Schema valueType, Object o, Pair<Text, Text> col, String fieldName) throws GoraException {
-
- // First of all we delete map field on ignite store
- Text rowKey = new Text(m.getRow());
- Query<K, T> query = newQuery();
- query.setFields(fieldName);
- query.setStartKey((K)rowKey.toString());
- query.setEndKey((K)rowKey.toString());
- deleteByQuery(query);
- flush();
- if (o == null){
- return 0;
- }
-
- Set<?> es = ((Map<?, ?>)o).entrySet();
- for (Object entry : es) {
- Object mapKey = ((Entry<?, ?>) entry).getKey();
- Object mapVal = ((Entry<?, ?>) entry).getValue();
- if ((o instanceof DirtyMapWrapper && ((DirtyMapWrapper<?, ?>)o).isDirty())
- || !(o instanceof DirtyMapWrapper)) {
- m.put(col.getFirst(), new Text(toBytes(mapKey)), new Value(toBytes(valueType, mapVal)));
- count++;
- }
- // TODO map value deletion
- }
- return count;
- }
-
- private int putArray(Mutation m, int count, Object o, Pair<Text, Text> col, String fieldName) throws GoraException {
-
- // First of all we delete array field on ignite store
- Text rowKey = new Text(m.getRow());
- Query<K, T> query = newQuery();
- query.setFields(fieldName);
- query.setStartKey((K)rowKey.toString());
- query.setEndKey((K)rowKey.toString());
- deleteByQuery(query);
- flush();
- if (o == null){
- return 0;
- }
-
- List<?> array = (List<?>) o; // both GenericArray and DirtyListWrapper
- int j = 0;
- for (Object item : array) {
- m.put(col.getFirst(), new Text(toBytes(j++)), new Value(toBytes(item)));
- count++;
- }
- return count;
+ public void put(K key, T obj) throws GoraException {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean delete(K key) throws GoraException {
- Query<K,T> q = newQuery();
- q.setKey(key);
- return deleteByQuery(q) > 0;
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
- public long deleteByQuery(Query<K,T> query) throws GoraException {
- try {
- Scanner scanner = createScanner(query);
- // add iterator that drops values on the server side
- scanner.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, SortedKeyIterator.class));
- RowIterator iterator = new RowIterator(scanner.iterator());
-
- long count = 0;
-
- while (iterator.hasNext()) {
- Iterator<Entry<Key,Value>> row = iterator.next();
- Mutation m = null;
- while (row.hasNext()) {
- Entry<Key,Value> entry = row.next();
- Key key = entry.getKey();
- if (m == null)
- m = new Mutation(key.getRow());
- // TODO optimize to avoid continually creating column vis? prob does not matter for empty
- m.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibility()), key.getTimestamp());
- }
- getBatchWriter().addMutation(m);
- count++;
- }
-
- return count;
- } catch (Exception e) {
- throw new GoraException(e);
- }
+ public long deleteByQuery(Query<K, T> query) throws GoraException {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
- private Range createRange(Query<K,T> query) {
- Text startRow = null;
- Text endRow = null;
-
- if (query.getStartKey() != null)
- startRow = new Text(toBytes(query.getStartKey()));
-
- if (query.getEndKey() != null)
- endRow = new Text(toBytes(query.getEndKey()));
-
- return new Range(startRow, true, endRow, true);
-
- }
-
- private Scanner createScanner(Query<K,T> query) throws TableNotFoundException {
- // TODO make isolated scanner optional?
- Scanner scanner = new IsolatedScanner(conn.createScanner(mapping.tableName, Authorizations.EMPTY));
- setFetchColumns(scanner, query.getFields());
-
- scanner.setRange(createRange(query));
-
- if (query.getStartTime() != -1 || query.getEndTime() != -1) {
- IteratorSetting is = new IteratorSetting(30, TimestampFilter.class);
- if (query.getStartTime() != -1)
- TimestampFilter.setStart(is, query.getStartTime(), true);
- if (query.getEndTime() != -1)
- TimestampFilter.setEnd(is, query.getEndTime(), true);
-
- scanner.addScanIterator(is);
- }
-
- return scanner;
- }
-
- /**
- * Execute the query and return the result.
- */
@Override
- public Result<K,T> execute(Query<K,T> query) throws GoraException {
- try {
- Scanner scanner = createScanner(query);
- return new IgniteResult<>(this, query, scanner);
- } catch (TableNotFoundException e) {
- throw new GoraException(e) ;
- }
+ public Result<K, T> execute(Query<K, T> query) throws GoraException {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
- public Query<K,T> newQuery() {
- return new IgniteQuery<>(this);
- }
-
- Text pad(Text key, int bytes) {
- if (key.getLength() < bytes)
- key = new Text(key);
-
- while (key.getLength() < bytes) {
- key.append(new byte[] {0}, 0, 1);
- }
-
- return key;
+ public Query<K, T> newQuery() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
- public List<PartitionQuery<K,T>> getPartitions(Query<K,T> query) throws GoraException {
- try {
- TabletLocator tl;
- if (conn instanceof MockConnector)
- tl = new MockTabletLocator();
- else
- tl = TabletLocator.getLocator(new ClientContext(conn.getInstance(), credentials, IgniteConfiguration.getTableConfiguration(conn, Tables.getTableId(conn.getInstance(), mapping.tableName))), new Text(Tables.getTableId(conn.getInstance(), mapping.tableName)));
-
- Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<>();
-
- tl.invalidateCache();
- while (tl.binRanges(new ClientContext(conn.getInstance(), credentials, IgniteConfiguration.getTableConfiguration(conn, Tables.getTableId(conn.getInstance(), mapping.tableName))), Collections.singletonList(createRange(query)), binnedRanges).size() > 0) {
- // TODO log?
- if (!Tables.exists(conn.getInstance(), Tables.getTableId(conn.getInstance(), mapping.tableName)))
- throw new TableDeletedException(Tables.getTableId(conn.getInstance(), mapping.tableName));
- else if (Tables.getTableState(conn.getInstance(), Tables.getTableId(conn.getInstance(), mapping.tableName)) == TableState.OFFLINE)
- throw new TableOfflineException(conn.getInstance(), Tables.getTableId(conn.getInstance(), mapping.tableName));
- UtilWaitThread.sleep(100);
- tl.invalidateCache();
- }
-
- List<PartitionQuery<K,T>> ret = new ArrayList<>();
-
- Text startRow = null;
- Text endRow = null;
- if (query.getStartKey() != null)
- startRow = new Text(toBytes(query.getStartKey()));
- if (query.getEndKey() != null)
- endRow = new Text(toBytes(query.getEndKey()));
-
- //hadoop expects hostnames, ignite keeps track of IPs... so need to convert
- HashMap<String,String> hostNameCache = new HashMap<>();
-
- for (Entry<String,Map<KeyExtent,List<Range>>> entry : binnedRanges.entrySet()) {
- String ip = entry.getKey().split(":", 2)[0];
- String location = hostNameCache.get(ip);
- if (location == null) {
- InetAddress inetAddress = InetAddress.getByName(ip);
- location = inetAddress.getHostName();
- hostNameCache.put(ip, location);
- }
-
- Map<KeyExtent,List<Range>> tablets = entry.getValue();
- for (KeyExtent ke : tablets.keySet()) {
-
- K startKey = null;
- if (startRow == null || !ke.contains(startRow)) {
- if (ke.getPrevEndRow() != null) {
- startKey = followingKey(encoder, getKeyClass(), getBytes(ke.getPrevEndRow()));
- }
- } else {
- startKey = fromBytes(getKeyClass(), getBytes(startRow));
- }
-
- K endKey = null;
- if (endRow == null || !ke.contains(endRow)) {
- if (ke.getEndRow() != null)
- endKey = lastPossibleKey(encoder, getKeyClass(), getBytes(ke.getEndRow()));
- } else {
- endKey = fromBytes(getKeyClass(), getBytes(endRow));
- }
-
- PartitionQueryImpl<K, T> pqi = new PartitionQueryImpl<>(query, startKey, endKey, location);
- pqi.setConf(getConf());
- ret.add(pqi);
- }
- }
-
- return ret;
- } catch (Exception e) {
- throw new GoraException(e);
- }
-
- }
-
- static <K> K lastPossibleKey(Encoder encoder, Class<K> clazz, byte[] er) {
-
- if (clazz.equals(Byte.TYPE) || clazz.equals(Byte.class)) {
- throw new UnsupportedOperationException();
- } else if (clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class)) {
- throw new UnsupportedOperationException();
- } else if (clazz.equals(Short.TYPE) || clazz.equals(Short.class)) {
- return fromBytes(encoder, clazz, encoder.lastPossibleKey(2, er));
- } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
- return fromBytes(encoder, clazz, encoder.lastPossibleKey(4, er));
- } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
- return fromBytes(encoder, clazz, encoder.lastPossibleKey(8, er));
- } else if (clazz.equals(Float.TYPE) || clazz.equals(Float.class)) {
- return fromBytes(encoder, clazz, encoder.lastPossibleKey(4, er));
- } else if (clazz.equals(Double.TYPE) || clazz.equals(Double.class)) {
- return fromBytes(encoder, clazz, encoder.lastPossibleKey(8, er));
- } else if (clazz.equals(String.class)) {
- throw new UnsupportedOperationException();
- } else if (clazz.equals(Utf8.class)) {
- return fromBytes(encoder, clazz, er);
- }
-
- throw new IllegalArgumentException(UNKOWN + clazz.getName());
- }
-
- @SuppressWarnings("unchecked")
- static <K> K followingKey(Encoder encoder, Class<K> clazz, byte[] per) {
-
- if (clazz.equals(Byte.TYPE) || clazz.equals(Byte.class)) {
- return (K) Byte.valueOf(encoder.followingKey(1, per)[0]);
- } else if (clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class)) {
- throw new UnsupportedOperationException();
- } else if (clazz.equals(Short.TYPE) || clazz.equals(Short.class)) {
- return fromBytes(encoder, clazz, encoder.followingKey(2, per));
- } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
- return fromBytes(encoder, clazz, encoder.followingKey(4, per));
- } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
- return fromBytes(encoder, clazz, encoder.followingKey(8, per));
- } else if (clazz.equals(Float.TYPE) || clazz.equals(Float.class)) {
- return fromBytes(encoder, clazz, encoder.followingKey(4, per));
- } else if (clazz.equals(Double.TYPE) || clazz.equals(Double.class)) {
- return fromBytes(encoder, clazz, encoder.followingKey(8, per));
- } else if (clazz.equals(String.class)) {
- throw new UnsupportedOperationException();
- } else if (clazz.equals(Utf8.class)) {
- return fromBytes(encoder, clazz, Arrays.copyOf(per, per.length + 1));
- }
-
- throw new IllegalArgumentException(UNKOWN + clazz.getName());
+ public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void flush() throws GoraException {
try {
- if (batchWriter != null) {
- batchWriter.flush();
- }
+ connection.commit();
} catch (Exception e) {
throw new GoraException(e);
}
@@ -1023,12 +183,11 @@ public class IgniteStore<K,T extends PersistentBase> extends DataStoreBase<K,T>
@Override
public void close() {
try {
- if (batchWriter != null) {
- batchWriter.close();
- batchWriter = null;
- }
- } catch (MutationsRejectedException e) {
- LOG.error(e.getMessage(), e);
+ connection.close();
+ LOG.info("Ignite datastore destroyed successfully.");
+ } catch (Exception ex) {
+ LOG.error(ex.getMessage(), ex);
}
}
+
}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/main/java/org/apache/gora/ignite/util/FixedByteArrayOutputStream.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/main/java/org/apache/gora/ignite/util/FixedByteArrayOutputStream.java b/gora-ignite/src/main/java/org/apache/gora/ignite/util/FixedByteArrayOutputStream.java
deleted file mode 100644
index 97fb46a..0000000
--- a/gora-ignite/src/main/java/org/apache/gora/ignite/util/FixedByteArrayOutputStream.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.util;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * It is a implementation of {@link java.io.OutputStream} must always provide at least a method that writes one byte of output.
- */
-public class FixedByteArrayOutputStream extends OutputStream {
-
- private int i;
- byte out[];
-
- public FixedByteArrayOutputStream(byte out[]) {
- this.out = out;
- }
-
- @Override
- public void write(int b) throws IOException {
- out[i++] = (byte) b;
- }
-
- @Override
- public void write(byte b[], int off, int len) throws IOException {
- System.arraycopy(b, off, out, i, len);
- i += len;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/main/java/org/apache/gora/ignite/util/package-info.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/main/java/org/apache/gora/ignite/util/package-info.java b/gora-ignite/src/main/java/org/apache/gora/ignite/util/package-info.java
deleted file mode 100644
index eedb84b..0000000
--- a/gora-ignite/src/main/java/org/apache/gora/ignite/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package contains Ignite store related util classes.
- */
-package org.apache.gora.ignite.util;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/GoraIgniteTestDriver.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/GoraIgniteTestDriver.java b/gora-ignite/src/test/java/org/apache/gora/ignite/GoraIgniteTestDriver.java
index 1e03717..336d81b 100644
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/GoraIgniteTestDriver.java
+++ b/gora-ignite/src/test/java/org/apache/gora/ignite/GoraIgniteTestDriver.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -17,57 +17,32 @@
*/
package org.apache.gora.ignite;
-import org.apache.ignite.minicluster.MiniIgniteCluster;
-import org.apache.ignite.minicluster.MiniIgniteConfig;
import org.apache.gora.GoraTestDriver;
import org.apache.gora.ignite.store.IgniteStore;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
/**
- * @author lmcgibbn
+ * Helper class for third part tests using gora-ignite backend.
*
+ * @see GoraTestDriver
*/
public class GoraIgniteTestDriver extends GoraTestDriver {
- private static final Logger LOG = LoggerFactory.getLogger(GoraIgniteTestDriver.class);
- private static MiniIgniteCluster cluster = null;
- private static final String PASSWORD = "drowssap";
+ private Ignite igniteInstance;
- @Rule
- public TemporaryFolder tmpDir = new TemporaryFolder();
-
- public GoraIgniteTestDriver() throws Exception {
+ public GoraIgniteTestDriver() {
super(IgniteStore.class);
}
@Override
- public void setUpClass() throws IOException, InterruptedException {
- log.info("Starting Ignite MiniIgniteCluster...");
- try {
- tmpDir.create();
- MiniIgniteConfig miniCfg = new MiniIgniteConfig(tmpDir.getRoot(), PASSWORD);
- miniCfg.setInstanceName("goraTest");
- miniCfg.setZooKeeperPort(56321);
- cluster = new MiniIgniteCluster(miniCfg);
- cluster.start();
- } catch (Exception e) {
- LOG.error("Error starting Ignite MiniIgniteCluster: {}", e.getMessage());
- // cleanup
- tearDownClass();
- }
+ public void setUpClass() throws Exception {
+ igniteInstance = Ignition.start();
}
@Override
- public void tearDownClass() throws IOException, InterruptedException {
- log.info("Shutting down Ignite MiniIgniteCluster...");
- if (cluster != null) {
- cluster.stop();
- }
- tmpDir.delete();
+ public void tearDownClass() throws Exception {
+ igniteInstance.close();
}
+
}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/package-info.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/package-info.java b/gora-ignite/src/test/java/org/apache/gora/ignite/package-info.java
deleted file mode 100644
index f536961..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * Tests for <code>gora-ignite</code> including
- * the test driver for {@link org.apache.gora.ignite.store.IgniteStoreTest}
- */
-package org.apache.gora.ignite;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/store/AuthenticationTokenTest.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/store/AuthenticationTokenTest.java b/gora-ignite/src/test/java/org/apache/gora/ignite/store/AuthenticationTokenTest.java
deleted file mode 100644
index bb77bee..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/store/AuthenticationTokenTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.store;
-
-import java.util.List;
-import java.util.Properties;
-import org.apache.ignite.minicluster.MiniIgniteCluster;
-import org.apache.gora.examples.generated.Employee;
-import org.apache.gora.query.PartitionQuery;
-import org.apache.gora.store.DataStore;
-import org.apache.gora.store.DataStoreFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tests authentication token is serialized correctly.
- */
-public class AuthenticationTokenTest {
- private static final Logger LOG = LoggerFactory.getLogger(AuthenticationTokenTest.class);
-
- private static final String GORA_DATASTORE =
- DataStoreFactory.GORA + "." + DataStoreFactory.DATASTORE + ".";
- private static final String PASSWORD = "password";
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private MiniIgniteCluster cluster;
- private DataStore<String, Employee> employeeStore;
-
- @Before
- @SuppressWarnings("unchecked")
- public void setUp() throws Exception {
- cluster = new MiniIgniteCluster(temporaryFolder.getRoot(), PASSWORD);
- cluster.start();
-
- Properties properties = DataStoreFactory.createProps();
- properties.setProperty(
- GORA_DATASTORE + IgniteStore.MOCK_PROPERTY,
- "false");
- properties.setProperty(
- GORA_DATASTORE + IgniteStore.INSTANCE_NAME_PROPERTY,
- cluster.getInstanceName());
- properties.setProperty(
- GORA_DATASTORE + IgniteStore.ZOOKEEPERS_NAME_PROPERTY,
- cluster.getZooKeepers());
- properties.setProperty(
- GORA_DATASTORE + IgniteStore.PASSWORD_PROPERTY,
- PASSWORD);
-
- employeeStore = DataStoreFactory.createDataStore(
- IgniteStore.class,
- String.class,
- Employee.class,
- new Configuration(),
- properties);
- }
-
- @After
- public void tearDown() throws Exception {
- cluster.stop();
- }
-
- @Test
- public void testAuthenticationTokenIsSerializedCorrectly() throws Exception {
- List<PartitionQuery<String, Employee>> partitions =
- employeeStore.getPartitions(employeeStore.newQuery());
- LOG.debug("partitions {}", partitions);
- }
-}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/store/IgniteStoreTest.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/store/IgniteStoreTest.java b/gora-ignite/src/test/java/org/apache/gora/ignite/store/IgniteStoreTest.java
deleted file mode 100644
index b42d344..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/store/IgniteStoreTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.store;
-
-import java.io.IOException;
-
-import org.apache.gora.ignite.GoraIgniteTestDriver;
-import org.apache.gora.examples.generated.Employee;
-import org.apache.gora.examples.generated.WebPage;
-import org.apache.gora.store.DataStore;
-import org.apache.gora.store.DataStoreFactory;
-import org.apache.gora.store.DataStoreTestBase;
-import static org.apache.gora.store.DataStoreTestBase.log;
-import org.apache.gora.store.DataStoreTestUtil;
-import static org.apache.gora.store.DataStoreTestUtil.testResultSize;
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Tests extending {@link org.apache.gora.store.DataStoreTestBase}
- * which run the base JUnit test suite for Gora.
- */
-public class IgniteStoreTest extends DataStoreTestBase {
-
- static {
- try {
- setTestDriver(new GoraIgniteTestDriver());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public GoraIgniteTestDriver getTestDriver() {
- return (GoraIgniteTestDriver) testDriver;
- }
-
- //Until GORA-66 is resolved this test will always fail, so
- //do not run it
- @Ignore("skipped until GORA-66 is resolved")
- @Override
- public void testDeleteByQueryFields() throws IOException {
- }
-
- @Test
- @Ignore("Ignite does not support Result#size() without limit set")
- @Override
- public void testResultSize() throws Exception {
- }
-
- @Test
- @Ignore("Ignite does not support Result#size() without limit set")
- @Override
- public void testResultSizeStartKey() throws Exception {
- }
-
- @Ignore("Ignite does not support Result#size() without limit set")
- @Override
- public void testResultSizeEndKey() throws Exception {
- }
-
- @Test
- @Ignore("Ignite does not support Result#size() without limit set")
- @Override
- public void testResultSizeKeyRange() throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/store/PartitionTest.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/store/PartitionTest.java b/gora-ignite/src/test/java/org/apache/gora/ignite/store/PartitionTest.java
deleted file mode 100644
index 1c77656..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/store/PartitionTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.store;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.apache.gora.ignite.encoders.Encoder;
-import org.apache.gora.ignite.encoders.SignedBinaryEncoder;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class PartitionTest {
- // TODO test more types
-
- private static Encoder encoder = new SignedBinaryEncoder();
-
- static long encl(long l) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(baos);
- try {
- dos.writeLong(l);
- dos.flush();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return encoder.decodeLong(baos.toByteArray());
- }
-
- @Test
- public void test1() throws IOException {
- assertEquals(encl(0x006f000000000000l), (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
- assertEquals(encl(1l), (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {0, 0, 0, 0, 0, 0, 0, 0}));
- assertEquals(encl(0x106f000000000001l), (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {0x10, 0x6f, 0, 0, 0, 0, 0, 0}));
- assertEquals(
- encl(-1l),
- (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff,
- (byte) 0xfe}));
-
- assertEquals(encl(0x8000000000000001l), (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {(byte) 0x80, 0, 0, 0, 0, 0, 0, 0}));
- assertEquals(
- encl(0x8000000000000000l),
- (long) IgniteStore.followingKey(encoder, Long.class, new byte[] {(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff,
- (byte) 0xff}));
-
-
- try {
- IgniteStore.followingKey(encoder, Long.class,
- new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff});
- assertTrue(false);
- } catch (IllegalArgumentException iea) {
-
- }
- }
-
- @Test
- public void test2() throws IOException {
- assertEquals(encl(0x00ffffffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {0x01}));
- assertEquals(encl(0x006effffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
- assertEquals(encl(0xff6effffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, 0x6f}));
- assertEquals(encl(0xfffeffffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, (byte) 0xff}));
- assertEquals(encl(0l), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0, 0, 0, 0, 0, 0, 0, 0}));
-
- assertEquals(encl(0x7effffffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x7f}));
- assertEquals(encl(0x7fffffffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x80}));
- assertEquals(encl(0x80ffffffffffffffl), (long) IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x81}));
-
- try {
- IgniteStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0, 0, 0, 0, 0, 0, 0});
- assertTrue(false);
- } catch (IllegalArgumentException iea) {
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/store/TestIgniteStore.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/store/TestIgniteStore.java b/gora-ignite/src/test/java/org/apache/gora/ignite/store/TestIgniteStore.java
new file mode 100644
index 0000000..2244f0e
--- /dev/null
+++ b/gora-ignite/src/test/java/org/apache/gora/ignite/store/TestIgniteStore.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.gora.ignite.store;
+
+import org.apache.gora.ignite.GoraIgniteTestDriver;
+import org.apache.gora.store.DataStoreTestBase;
+
+/**
+ * Test case for IgniteStore.
+ */
+public class TestIgniteStore extends DataStoreTestBase {
+
+ static {
+ setTestDriver(new GoraIgniteTestDriver());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/store/package-info.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/store/package-info.java b/gora-ignite/src/test/java/org/apache/gora/ignite/store/package-info.java
deleted file mode 100644
index a41e085..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/store/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package contains all the unit tests for basic CRUD operations
- * functionality of the Ignite dataStore.
- */
-package org.apache.gora.ignite.store;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/util/HexEncoderTest.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/util/HexEncoderTest.java b/gora-ignite/src/test/java/org/apache/gora/ignite/util/HexEncoderTest.java
deleted file mode 100644
index 0d4e5e6..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/util/HexEncoderTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.util;
-
-import java.nio.charset.Charset;
-import org.apache.gora.ignite.encoders.HexEncoder;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-/**
- *
- */
-public class HexEncoderTest {
-
- @Test
- public void testByte() {
- HexEncoder encoder = new HexEncoder();
-
- assertEquals("12", new String(encoder.encodeByte((byte) 0x12), Charset.defaultCharset()));
- assertEquals("f2", new String(encoder.encodeByte((byte) 0xf2), Charset.defaultCharset()));
-
- byte b = Byte.MIN_VALUE;
- while (b != Byte.MAX_VALUE) {
- assertEquals(b, encoder.decodeByte(encoder.encodeByte(b)));
- b++;
- }
- }
-
- @Test
- public void testShort() {
- HexEncoder encoder = new HexEncoder();
-
- assertEquals("1234", new String(encoder.encodeShort((short) 0x1234), Charset.defaultCharset()));
- assertEquals("f234", new String(encoder.encodeShort((short) 0xf234), Charset.defaultCharset()));
-
- short s = Short.MIN_VALUE;
- while (s != Short.MAX_VALUE) {
- assertEquals(s, encoder.decodeShort(encoder.encodeShort(s)));
- s++;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/util/SignedBinaryEncoderTest.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/util/SignedBinaryEncoderTest.java b/gora-ignite/src/test/java/org/apache/gora/ignite/util/SignedBinaryEncoderTest.java
deleted file mode 100644
index c943e73..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/util/SignedBinaryEncoderTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.gora.ignite.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-
-import org.apache.gora.ignite.encoders.SignedBinaryEncoder;
-import org.apache.hadoop.io.Text;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-public class SignedBinaryEncoderTest {
- @Test
- public void testShort() throws IOException {
- short s = Short.MIN_VALUE;
- Text prev = null;
-
- SignedBinaryEncoder encoder = new SignedBinaryEncoder();
-
- while (true) {
- byte[] enc = encoder.encodeShort(s);
- assertEquals(s, encoder.decodeShort(enc));
- Text current = new Text(enc);
- if (prev != null)
- assertTrue(prev.compareTo(current) < 0);
- prev = current;
- s++;
- if (s == Short.MAX_VALUE)
- break;
- }
- }
-
- private void testInt(int start, int finish) throws IOException {
- int i = start;
- Text prev = null;
-
- SignedBinaryEncoder encoder = new SignedBinaryEncoder();
-
- while (true) {
- byte[] enc = encoder.encodeInt(i);
- assertEquals(i, encoder.decodeInt(enc));
- Text current = new Text(enc);
- if (prev != null)
- assertTrue(prev.compareTo(current) < 0);
- prev = current;
- i++;
- if (i == finish)
- break;
- }
- }
-
- @Test
- public void testInt() throws IOException {
- testInt(Integer.MIN_VALUE, Integer.MIN_VALUE + (1 << 16));
- testInt(-(1 << 15), (1 << 15));
- testInt(Integer.MAX_VALUE - (1 << 16), Integer.MAX_VALUE);
- }
-
- private void testLong(long start, long finish) throws IOException {
- long l = start;
- Text prev = null;
-
- SignedBinaryEncoder encoder = new SignedBinaryEncoder();
-
- while (true) {
- byte[] enc = encoder.encodeLong(l);
- assertEquals(l, encoder.decodeLong(enc));
- Text current = new Text(enc);
- if (prev != null)
- assertTrue(prev.compareTo(current) < 0);
- prev = current;
- l++;
- if (l == finish)
- break;
- }
- }
-
- @Test
- public void testLong() throws IOException {
- testLong(Long.MIN_VALUE, Long.MIN_VALUE + (1 << 16));
- testLong(-(1 << 15), (1 << 15));
- testLong(Long.MAX_VALUE - (1 << 16), Long.MAX_VALUE);
- }
-
- @Test
- public void testDouble() throws IOException {
-
- ArrayList<Double> testData = new ArrayList<>();
- testData.add(Double.NEGATIVE_INFINITY);
- testData.add(Double.MIN_VALUE);
- testData.add(Math.nextUp(Double.NEGATIVE_INFINITY));
- testData.add(Math.pow(10.0, 30.0) * -1.0);
- testData.add(Math.pow(10.0, 30.0));
- testData.add(Math.pow(10.0, -30.0) * -1.0);
- testData.add(Math.pow(10.0, -30.0));
- testData.add(Math.nextAfter(0.0, Double.NEGATIVE_INFINITY));
- testData.add(0.0);
- testData.add(Math.nextAfter(Double.MAX_VALUE, Double.NEGATIVE_INFINITY));
- testData.add(Double.MAX_VALUE);
- testData.add(Double.POSITIVE_INFINITY);
-
- Collections.sort(testData);
-
- SignedBinaryEncoder encoder = new SignedBinaryEncoder();
-
- for (int i = 0; i < testData.size(); i++) {
- byte[] enc = encoder.encodeDouble(testData.get(i));
- assertEquals(testData.get(i), (Double) encoder.decodeDouble(enc));
- if (i > 1) {
- assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
- new Text(enc).compareTo(new Text(encoder.encodeDouble(testData.get(i - 1)))) > 0);
- }
- }
- }
-
- @Test
- public void testFloat() throws IOException {
-
- ArrayList<Float> testData = new ArrayList<>();
- testData.add(Float.NEGATIVE_INFINITY);
- testData.add(Float.MIN_VALUE);
- testData.add(Math.nextUp(Float.NEGATIVE_INFINITY));
- testData.add((float) Math.pow(10.0f, 30.0f) * -1.0f);
- testData.add((float) Math.pow(10.0f, 30.0f));
- testData.add((float) Math.pow(10.0f, -30.0f) * -1.0f);
- testData.add((float) Math.pow(10.0f, -30.0f));
- testData.add(Math.nextAfter(0.0f, Float.NEGATIVE_INFINITY));
- testData.add(0.0f);
- testData.add(Math.nextAfter(Float.MAX_VALUE, Float.NEGATIVE_INFINITY));
- testData.add(Float.MAX_VALUE);
- testData.add(Float.POSITIVE_INFINITY);
-
- Collections.sort(testData);
-
- SignedBinaryEncoder encoder = new SignedBinaryEncoder();
-
- for (int i = 0; i < testData.size(); i++) {
- byte[] enc = encoder.encodeFloat(testData.get(i));
- assertEquals(testData.get(i), (Float)encoder.decodeFloat(enc));
- if (i > 1) {
- assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
- new Text(enc).compareTo(new Text(encoder.encodeFloat(testData.get(i - 1)))) > 0);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/java/org/apache/gora/ignite/util/package-info.java
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/java/org/apache/gora/ignite/util/package-info.java b/gora-ignite/src/test/java/org/apache/gora/ignite/util/package-info.java
deleted file mode 100644
index afcd619..0000000
--- a/gora-ignite/src/test/java/org/apache/gora/ignite/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/**
- * This package contains all the unit tests for utils of the Ignite dataStore.
- */
-package org.apache.gora.ignite.util;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/resources/gora-accumulo-mapping.xml
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/resources/gora-accumulo-mapping.xml b/gora-ignite/src/test/resources/gora-accumulo-mapping.xml
deleted file mode 100644
index 4d036c6..0000000
--- a/gora-ignite/src/test/resources/gora-accumulo-mapping.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-
-<gora-otd>
- <table name="AccessLog">
- <config key="table.file.compress.blocksize" value="32K"/>
- </table>
-
- <class name="org.apache.gora.tutorial.log.generated.Pageview" keyClass="java.lang.Long" table="AccessLog">
- <field name="url" family="common" qualifier="url"/>
- <field name="timestamp" family="common" qualifier="timestamp"/>
- <field name="ip" family="common" qualifier="ip" />
- <field name="httpMethod" family="http" qualifier="httpMethod"/>
- <field name="httpStatusCode" family="http" qualifier="httpStatusCode"/>
- <field name="responseSize" family="http" qualifier="responseSize"/>
- <field name="referrer" family="misc" qualifier="referrer"/>
- <field name="userAgent" family="misc" qualifier="userAgent"/>
- </class>
-
- <class name="org.apache.gora.examples.generated.Employee" keyClass="java.lang.String" table="Employee">
- <field name="name" family="info" qualifier="nm"/>
- <field name="dateOfBirth" family="info" qualifier="db"/>
- <field name="ssn" family="info" qualifier="sn"/>
- <field name="salary" family="info" qualifier="sl"/>
- <field name="boss" family="info" qualifier="bs"/>
- <field name="webpage" family="info" qualifier="wp"/>
- </class>
-
- <class name="org.apache.gora.examples.generated.WebPage" keyClass="java.lang.String" table="WebPage">
- <field name="url" family="common" qualifier="u"/>
- <field name="content" family="content" qualifier="c"/>
- <field name="parsedContent" family="parsedContent"/>
- <field name="outlinks" family="outlinks"/>
- <field name="headers" family="headers"/>
- <field name="metadata" family="common" qualifier="metadata"/>
- <field name="byteData" family="byteData" qualifier="byteData"/>
- <field name="stringData" family="stringData" qualifier="stringData"/>
- </class>
-
- <class name="org.apache.gora.examples.generated.TokenDatum" keyClass="java.lang.String">
- <field name="count" family="common" qualifier="count"/>
- </class>
-</gora-otd>
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/resources/gora-ignite-mapping.xml
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/resources/gora-ignite-mapping.xml b/gora-ignite/src/test/resources/gora-ignite-mapping.xml
new file mode 100644
index 0000000..3c13774
--- /dev/null
+++ b/gora-ignite/src/test/resources/gora-ignite-mapping.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<gora-otd>
+ <class name="org.apache.gora.examples.generated.Employee" keyClass="java.lang.String" table="Employee">
+ <primarykey column="ssn"/>
+ <field name="ssn" column="ssn" type="VARCHAR"/>
+ <field name="name" column="name" type="VARCHAR"/>
+ <field name="dateOfBirth" column="dateOfBirth" type="BIGINT"/>
+ <field name="salary" column="salary" type="INT"/>
+ <field name="boss" column="boss" type="VARCHAR"/>
+ <field name="webpage" column="webpage" type="VARCHAR"/>
+ </class>
+
+ <class name="org.apache.gora.examples.generated.WebPage" keyClass="java.lang.String" table="WebPage">
+ <primarykey column="url"/>
+ <field name="url" column="url" type="VARCHAR"/>
+ <field name="content" column="content" type="BINARY"/>
+ <field name="parsedContent" column="parsedContent" type="BINARY"/>
+ <field name="outlinks" column="outlinks" type="BINARY"/>
+ <field name="headers" column="headers" type="BINARY"/>
+ <field name="metadata" column="metadata" type="BINARY"/>
+ <field name="byteData" column="byteData" type="BINARY"/>
+ <field name="stringData" column="stringData" type="VARCHAR"/>
+ </class>
+</gora-otd>
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/gora-ignite/src/test/resources/gora.properties
----------------------------------------------------------------------
diff --git a/gora-ignite/src/test/resources/gora.properties b/gora-ignite/src/test/resources/gora.properties
index 5cf0e25..e45aab7 100644
--- a/gora-ignite/src/test/resources/gora.properties
+++ b/gora-ignite/src/test/resources/gora.properties
@@ -14,8 +14,9 @@
# limitations under the License.
gora.datastore.default=org.apache.gora.ignite.store.IgniteStore
-gora.datastore.ignite.mock=false
-gora.datastore.ignite.instance=goraTest
-gora.datastore.ignite.zookeepers=localhost:56321
-gora.datastore.ignite.user=root
-gora.datastore.ignite.password=drowssap
\ No newline at end of file
+gora.datastore.ignite.schema=PUBLIC
+gora.datastore.ignite.host=localhost
+gora.datastore.ignite.port=10800
+gora.datastore.ignite.user=
+gora.datastore.ignite.password=
+gora.datastore.ignite.additionalConfigurations=
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/gora/blob/7545170d/nbactions.xml
----------------------------------------------------------------------
diff --git a/nbactions.xml b/nbactions.xml
new file mode 100644
index 0000000..52ecdda
--- /dev/null
+++ b/nbactions.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>rebuild</actionName>
+ <packagings>
+ <packaging>*</packaging>
+ </packagings>
+ <goals>
+ <goal>clean</goal>
+ <goal>install</goal>
+ </goals>
+ </action>
+ </actions>