You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/10/21 12:34:38 UTC
ignite git commit: IGNITE-1753 WIP on reworking JDBC POJO store to
new configuration.
Repository: ignite
Updated Branches:
refs/heads/ignite-1753 [created] 10e4dbe2b
IGNITE-1753 WIP on reworking JDBC POJO store to new configuration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10e4dbe2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10e4dbe2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10e4dbe2
Branch: refs/heads/ignite-1753
Commit: 10e4dbe2b9a3b7ec90871ca92e85a86b8c0c33ff
Parents: e7eb2b3
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Oct 21 17:34:04 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Oct 21 17:34:04 2015 +0700
----------------------------------------------------------------------
.../jdbc/CacheJdbcPojoStoreConfiguration.java | 59 ++++++
.../store/jdbc/CacheJdbcPojoStoreType.java | 201 +++++++++++++++++++
.../store/jdbc/CacheJdbcPojoStoreTypeField.java | 45 +++++
3 files changed, 305 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/10e4dbe2/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreConfiguration.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreConfiguration.java
new file mode 100644
index 0000000..86ef32b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+import java.io.Serializable;
+import org.apache.ignite.cache.store.jdbc.dialect.JdbcDialect;
+
+/**
+ * JDBC POJO store configuration.
+ */
+public class CacheJdbcPojoStoreConfiguration implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Default value for write attempts. */
+ protected static final int DFLT_WRITE_ATTEMPTS = 2;
+
+ /** Default batch size for put and remove operations. */
+ protected static final int DFLT_BATCH_SIZE = 512;
+
+ /** Default batch size for put and remove operations. */
+ protected static final int DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD = 512;
+
+ /** Types that store could process. */
+ private CacheJdbcPojoStoreType[] types;
+
+ /** Name of data source bean. */
+ private String dataSrcBean;
+
+ /** Database dialect. */
+ protected JdbcDialect dialect;
+
+ /** Max workers thread count. These threads are responsible for load cache. */
+ private int maxPoolSz = Runtime.getRuntime().availableProcessors();
+
+ /** Maximum batch size for writeAll and deleteAll operations. */
+ private int maxWrtAttempts = DFLT_WRITE_ATTEMPTS;
+
+ /** Maximum batch size for writeAll and deleteAll operations. */
+ private int batchSz = DFLT_BATCH_SIZE;
+
+ /** Parallel load cache minimum threshold. If {@code 0} then load sequentially. */
+ private int parallelLoadCacheMinThreshold = DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD;
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10e4dbe2/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreType.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreType.java
new file mode 100644
index 0000000..ed8daf5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreType.java
@@ -0,0 +1,201 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+import java.io.Serializable;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+
+/**
+ * Description for type that could be stored into database by store.
+ */
+public class CacheJdbcPojoStoreType implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Schema name in database. */
+ private String dbSchema;
+
+ /** Table name in database. */
+ private String dbTbl;
+
+ /** Key class used to store key in cache. */
+ private String keyType;
+
+ /** Value class used to store value in cache. */
+ private String valType;
+
+ /** List of fields descriptors for key object. */
+ @GridToStringInclude
+ private CacheJdbcPojoStoreTypeField[] keyFields;
+
+ /** List of fields descriptors for value object. */
+ @GridToStringInclude
+ private CacheJdbcPojoStoreTypeField[] valFields;
+
+ /** If {@code true} object is stored as IgniteObject. */
+ private boolean keepSerialized;
+
+ /**
+ * Gets database schema name.
+ *
+ * @return Schema name.
+ */
+ public String getDatabaseSchema() {
+ return dbSchema;
+ }
+
+ /**
+ * Sets database schema name.
+ *
+ * @param dbSchema Schema name.
+ */
+ public CacheJdbcPojoStoreType setDatabaseSchema(String dbSchema) {
+ this.dbSchema = dbSchema;
+
+ return this;
+ }
+
+ /**
+ * Gets table name in database.
+ *
+ * @return Table name in database.
+ */
+ public String getDatabaseTable() {
+ return dbTbl;
+ }
+
+ /**
+ * Table name in database.
+ *
+ * @param dbTbl Table name in database.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setDatabaseTable(String dbTbl) {
+ this.dbTbl = dbTbl;
+
+ return this;
+ }
+
+ /**
+ * Gets key type.
+ *
+ * @return Key type.
+ */
+ public String getKeyType() {
+ return keyType;
+ }
+
+ /**
+ * Sets key type.
+ *
+ * @param keyType Key type.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setKeyType(String keyType) {
+ this.keyType = keyType;
+
+ return this;
+ }
+
+ /**
+ * Sets key type.
+ *
+ * @param cls Key type class.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setKeyType(Class<?> cls) {
+ setKeyType(cls.getName());
+
+ return this;
+ }
+
+ /**
+ * Gets value type.
+ *
+ * @return Key type.
+ */
+ public String getValueType() {
+ return valType;
+ }
+
+ /**
+ * Sets value type.
+ *
+ * @param valType Value type.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setValueType(String valType) {
+ this.valType = valType;
+
+ return this;
+ }
+
+ /**
+ * Sets value type.
+ *
+ * @param cls Value type class.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setValueType(Class<?> cls) {
+ setValueType(cls.getName());
+
+ return this;
+ }
+
+ /**
+ * Gets optional persistent key fields (needed only if {@link CacheJdbcPojoStore} is used).
+ *
+ * @return Persistent key fields.
+ */
+ public CacheJdbcPojoStoreTypeField[] getKeyFields() {
+ return keyFields;
+ }
+
+ /**
+ * Sets optional persistent key fields (needed only if {@link CacheJdbcPojoStore} is used).
+ *
+ * @param keyFields Persistent key fields.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setKeyFields(CacheJdbcPojoStoreTypeField... keyFields) {
+ this.keyFields = keyFields;
+
+ return this;
+ }
+
+ /**
+ * Gets optional persistent value fields (needed only if {@link CacheJdbcPojoStore} is used).
+ *
+ * @return Persistent value fields.
+ */
+ public CacheJdbcPojoStoreTypeField[] getValueFields() {
+ return valFields;
+ }
+
+ /**
+ * Sets optional persistent value fields (needed only if {@link CacheJdbcPojoStore} is used).
+ *
+ * @param valFields Persistent value fields.
+ * @return {@code this} for chaining.
+ */
+ public CacheJdbcPojoStoreType setValueFields(CacheJdbcPojoStoreTypeField... valFields) {
+ this.valFields = valFields;
+
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10e4dbe2/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTypeField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTypeField.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTypeField.java
new file mode 100644
index 0000000..4c63aea
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTypeField.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ignite.cache.store.jdbc;
+
+/**
+ * Description of how field declared in database and in cache.
+ */
+public class CacheJdbcPojoStoreTypeField {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Field name in database. */
+ private String dbFieldName;
+
+ /** Field JDBC type in database. */
+ private int dbFieldType;
+
+ /** Field name in java object. */
+ private String javaFieldName;
+
+ /** Field java type. */
+ private Class<?> javaFieldType;
+
+ /**
+ * Default constructor.
+ */
+ public CacheJdbcPojoStoreTypeField() {
+ // No-op.
+ }
+}