You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ga...@apache.org on 2017/11/02 16:23:05 UTC
[03/12] hive git commit: HIVE-17812 Move remaining classes that
HiveMetaStore depends on. This closes #261. (Alan Gates,
reviewed by Vihang Karajgaonkar)
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java
new file mode 100644
index 0000000..78259ba
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java
@@ -0,0 +1,33 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Index;
+
+public abstract class AlterIndexMessage extends EventMessage {
+
+ public abstract Index getIndexObjBefore() throws Exception;
+
+ public abstract Index getIndexObjAfter() throws Exception;
+
+ protected AlterIndexMessage() {
+ super(EventType.ALTER_INDEX);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java
new file mode 100644
index 0000000..aaa7ef5
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java
@@ -0,0 +1,69 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+import java.util.Map;
+
+public abstract class AlterPartitionMessage extends EventMessage {
+
+ protected AlterPartitionMessage() {
+ super(EventType.ALTER_PARTITION);
+ }
+
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ public abstract boolean getIsTruncateOp();
+
+ public abstract Map<String,String> getKeyValues();
+
+ public abstract Table getTableObj() throws Exception;
+
+ public abstract Partition getPtnObjBefore() throws Exception;
+
+ public abstract Partition getPtnObjAfter() throws Exception;
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null) throw new IllegalStateException("Table name unset.");
+ if (getKeyValues() == null) throw new IllegalStateException("Partition values unset");
+ try {
+ if (getTableObj() == null){
+ throw new IllegalStateException("Table object not set.");
+ }
+ if (getPtnObjAfter() == null){
+ throw new IllegalStateException("Partition object(after) not set.");
+ }
+ if (getPtnObjBefore() == null){
+ throw new IllegalStateException("Partition object(before) not set.");
+ }
+ } catch (Exception e) {
+ if (! (e instanceof IllegalStateException)){
+ throw new IllegalStateException("Event not set up correctly",e);
+ } else {
+ throw (IllegalStateException) e;
+ }
+ }
+ return super.checkValid();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java
new file mode 100644
index 0000000..30e2862
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java
@@ -0,0 +1,58 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public abstract class AlterTableMessage extends EventMessage {
+
+ protected AlterTableMessage() {
+ super(EventType.ALTER_TABLE);
+ }
+
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ public abstract boolean getIsTruncateOp();
+
+ public abstract Table getTableObjBefore() throws Exception;
+
+ public abstract Table getTableObjAfter() throws Exception;
+
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null) throw new IllegalStateException("Table name unset.");
+ try {
+ if (getTableObjAfter() == null){
+ throw new IllegalStateException("Table object(after) not set.");
+ }
+ if (getTableObjBefore() == null){
+ throw new IllegalStateException("Table object(before) not set.");
+ }
+ } catch (Exception e) {
+ if (! (e instanceof IllegalStateException)){
+ throw new IllegalStateException("Event not set up correctly",e);
+ } else {
+ throw (IllegalStateException) e;
+ }
+ }
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateDatabaseMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateDatabaseMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateDatabaseMessage.java
new file mode 100644
index 0000000..328c118
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateDatabaseMessage.java
@@ -0,0 +1,28 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+public abstract class CreateDatabaseMessage extends EventMessage {
+
+ protected CreateDatabaseMessage() {
+ super(EventType.CREATE_DATABASE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateFunctionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateFunctionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateFunctionMessage.java
new file mode 100644
index 0000000..5478143
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateFunctionMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Function;
+
+public abstract class CreateFunctionMessage extends EventMessage {
+
+ protected CreateFunctionMessage() {
+ super(EventType.CREATE_FUNCTION);
+ }
+
+ public abstract Function getFunctionObj() throws Exception;
+
+ @Override
+ public EventMessage checkValid() {
+ try {
+ if (getFunctionObj() == null)
+ throw new IllegalStateException("Function object unset.");
+ } catch (Exception e) {
+ if (! (e instanceof IllegalStateException)){
+ throw new IllegalStateException("Event not set up correctly", e);
+ } else {
+ throw (IllegalStateException) e;
+ }
+ }
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java
new file mode 100644
index 0000000..f107100
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Index;
+
+public abstract class CreateIndexMessage extends EventMessage {
+
+ protected CreateIndexMessage() {
+ super(EventType.CREATE_INDEX);
+ }
+
+ public abstract Index getIndexObj() throws Exception;
+
+ @Override
+ public EventMessage checkValid() {
+ try {
+ if (getIndexObj() == null)
+ throw new IllegalStateException("Function object unset.");
+ } catch (Exception e) {
+ if (! (e instanceof IllegalStateException)){
+ throw new IllegalStateException("Event not set up correctly", e);
+ } else {
+ throw (IllegalStateException) e;
+ }
+ }
+ return super.checkValid();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java
new file mode 100644
index 0000000..49732ff
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java
@@ -0,0 +1,53 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public abstract class CreateTableMessage extends EventMessage {
+
+ protected CreateTableMessage() {
+ super(EventType.CREATE_TABLE);
+ }
+
+ /**
+ * Getter for the name of table created
+ * @return Table-name (String).
+ */
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ public abstract Table getTableObj() throws Exception;
+
+ /**
+ * Get list of files created as a result of this DML operation
+ *
+ * @return The iterable of files
+ */
+ public abstract Iterable<String> getFiles();
+
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null)
+ throw new IllegalStateException("Table name unset.");
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropConstraintMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropConstraintMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropConstraintMessage.java
new file mode 100644
index 0000000..95c9f9f
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropConstraintMessage.java
@@ -0,0 +1,29 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+public abstract class DropConstraintMessage extends EventMessage {
+ protected DropConstraintMessage() {
+ super(EventType.DROP_CONSTRAINT);
+ }
+
+ public abstract String getTable();
+
+ public abstract String getConstraint();
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropDatabaseMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropDatabaseMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropDatabaseMessage.java
new file mode 100644
index 0000000..a450d47
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropDatabaseMessage.java
@@ -0,0 +1,27 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+public abstract class DropDatabaseMessage extends EventMessage {
+
+ protected DropDatabaseMessage() {
+ super(EventType.DROP_DATABASE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropFunctionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropFunctionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropFunctionMessage.java
new file mode 100644
index 0000000..c418feb
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropFunctionMessage.java
@@ -0,0 +1,38 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+public abstract class DropFunctionMessage extends EventMessage {
+
+ public abstract String getFunctionName();
+
+ protected DropFunctionMessage() {
+ super(EventType.DROP_FUNCTION);
+ }
+
+ @Override
+ public EventMessage checkValid() {
+ if (getFunctionName() == null){
+ throw new IllegalStateException("Function name unset.");
+ }
+ return super.checkValid();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java
new file mode 100644
index 0000000..210b592
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+public abstract class DropIndexMessage extends EventMessage {
+
+ public abstract String getIndexName();
+ public abstract String getOrigTableName();
+ public abstract String getIndexTableName();
+
+ protected DropIndexMessage() {
+ super(EventType.DROP_INDEX);
+ }
+
+ @Override
+ public EventMessage checkValid() {
+ if (getIndexName() == null){
+ throw new IllegalStateException("Index name unset.");
+ }
+ if (getOrigTableName() == null){
+ throw new IllegalStateException("Index original table name unset.");
+ }
+ // NOTE: we do not do a not-null check on getIndexTableName,
+ // since, per the index design wiki, it can actually be null.
+
+ return super.checkValid();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java
new file mode 100644
index 0000000..fa7c9db
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java
@@ -0,0 +1,49 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public abstract class DropPartitionMessage extends EventMessage {
+
+ protected DropPartitionMessage() {
+ super(EventType.DROP_PARTITION);
+ }
+
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ public abstract Table getTableObj() throws Exception;
+
+ public abstract List<Map<String, String>> getPartitions ();
+
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null)
+ throw new IllegalStateException("Table name unset.");
+ if (getPartitions() == null)
+ throw new IllegalStateException("Partition-list unset.");
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java
new file mode 100644
index 0000000..b8e0e78
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java
@@ -0,0 +1,46 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Table;
+
+public abstract class DropTableMessage extends EventMessage {
+
+ protected DropTableMessage() {
+ super(EventType.DROP_TABLE);
+ }
+
+ /**
+ * Getter for the name of the table being dropped.
+ * @return Table-name (String).
+ */
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ public abstract Table getTableObj() throws Exception;
+
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null)
+ throw new IllegalStateException("Table name unset.");
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
new file mode 100644
index 0000000..7b22fac
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
@@ -0,0 +1,111 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+/**
+ * Class representing messages emitted when Metastore operations are done.
+ * (E.g. Creation and deletion of databases, tables and partitions.)
+ */
+public abstract class EventMessage {
+
+ /**
+ * Enumeration of all supported types of Metastore operations.
+ */
+ public enum EventType {
+
+ CREATE_DATABASE(MessageFactory.CREATE_DATABASE_EVENT),
+ DROP_DATABASE(MessageFactory.DROP_DATABASE_EVENT),
+ CREATE_TABLE(MessageFactory.CREATE_TABLE_EVENT),
+ DROP_TABLE(MessageFactory.DROP_TABLE_EVENT),
+ ADD_PARTITION(MessageFactory.ADD_PARTITION_EVENT),
+ DROP_PARTITION(MessageFactory.DROP_PARTITION_EVENT),
+ ALTER_TABLE(MessageFactory.ALTER_TABLE_EVENT),
+ ALTER_PARTITION(MessageFactory.ALTER_PARTITION_EVENT),
+ INSERT(MessageFactory.INSERT_EVENT),
+ CREATE_FUNCTION(MessageFactory.CREATE_FUNCTION_EVENT),
+ DROP_FUNCTION(MessageFactory.DROP_FUNCTION_EVENT),
+ CREATE_INDEX(MessageFactory.CREATE_INDEX_EVENT),
+ DROP_INDEX(MessageFactory.DROP_INDEX_EVENT),
+ ALTER_INDEX(MessageFactory.ALTER_INDEX_EVENT),
+ ADD_PRIMARYKEY(MessageFactory.ADD_PRIMARYKEY_EVENT),
+ ADD_FOREIGNKEY(MessageFactory.ADD_FOREIGNKEY_EVENT),
+ ADD_UNIQUECONSTRAINT(MessageFactory.ADD_UNIQUECONSTRAINT_EVENT),
+ ADD_NOTNULLCONSTRAINT(MessageFactory.ADD_NOTNULLCONSTRAINT_EVENT),
+ DROP_CONSTRAINT(MessageFactory.DROP_CONSTRAINT_EVENT);
+
+ private String typeString;
+
+ EventType(String typeString) {
+ this.typeString = typeString;
+ }
+
+ @Override
+ public String toString() { return typeString; }
+ }
+
+ protected EventType eventType;
+
+ protected EventMessage(EventType eventType) {
+ this.eventType = eventType;
+ }
+
+ public EventType getEventType() {
+ return eventType;
+ }
+
+ /**
+ * Getter for HCatalog Server's URL.
+ * (This is where the event originates from.)
+ * @return HCatalog Server's URL (String).
+ */
+ public abstract String getServer();
+
+ /**
+ * Getter for the Kerberos principal of the HCatalog service.
+ * @return HCatalog Service Principal (String).
+ */
+ public abstract String getServicePrincipal();
+
+ /**
+ * Getter for the name of the Database on which the Metastore operation is done.
+ * @return Database-name (String).
+ */
+ public abstract String getDB();
+
+ /**
+ * Getter for the timestamp associated with the operation.
+ * @return Timestamp (Long - seconds since epoch).
+ */
+ public abstract Long getTimestamp();
+
+ /**
+ * Class invariant. Checked after construction or deserialization.
+ */
+ public EventMessage checkValid() {
+ if (getServer() == null || getServicePrincipal() == null)
+ throw new IllegalStateException("Server-URL/Service-Principal shouldn't be null.");
+ if (getEventType() == null)
+ throw new IllegalStateException("Event-type unset.");
+ if (getDB() == null)
+ throw new IllegalArgumentException("DB-name unset.");
+
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java
new file mode 100644
index 0000000..c470097
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java
@@ -0,0 +1,75 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+/**
+ * HCat message sent when an insert is done to a table or partition.
+ */
+public abstract class InsertMessage extends EventMessage {
+
+ protected InsertMessage() {
+ super(EventType.INSERT);
+ }
+
+ /**
+ * Getter for the name of the table being insert into.
+ * @return Table-name (String).
+ */
+ public abstract String getTable();
+
+ public abstract String getTableType();
+
+ /**
+ * Getter for the replace flag being insert into/overwrite
+ * @return Replace flag to represent INSERT INTO or INSERT OVERWRITE (Boolean).
+ */
+ public abstract boolean isReplace();
+
+ /**
+ * Get list of file name and checksum created as a result of this DML operation
+ *
+ * @return The iterable of files
+ */
+ public abstract Iterable<String> getFiles();
+
+ /**
+ * Get the table object associated with the insert
+ *
+ * @return The Json format of Table object
+ */
+ public abstract Table getTableObj() throws Exception;
+
+ /**
+ * Get the partition object associated with the insert
+ *
+ * @return The Json format of Partition object if the table is partitioned else return null.
+ */
+ public abstract Partition getPtnObj() throws Exception;
+
+ @Override
+ public EventMessage checkValid() {
+ if (getTable() == null)
+ throw new IllegalStateException("Table name unset.");
+ return super.checkValid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java
new file mode 100644
index 0000000..810dc64
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java
@@ -0,0 +1,179 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+/**
+ * Interface for converting HCat events from String-form back to EventMessage instances.
+ */
+public abstract class MessageDeserializer {
+
+ /**
+ * Method to construct EventMessage from string.
+ */
+ public EventMessage getEventMessage(String eventTypeString, String messageBody) {
+
+ switch (EventMessage.EventType.valueOf(eventTypeString)) {
+ case CREATE_DATABASE:
+ return getCreateDatabaseMessage(messageBody);
+ case DROP_DATABASE:
+ return getDropDatabaseMessage(messageBody);
+ case CREATE_TABLE:
+ return getCreateTableMessage(messageBody);
+ case ALTER_TABLE:
+ return getAlterTableMessage(messageBody);
+ case DROP_TABLE:
+ return getDropTableMessage(messageBody);
+ case ADD_PARTITION:
+ return getAddPartitionMessage(messageBody);
+ case ALTER_PARTITION:
+ return getAlterPartitionMessage(messageBody);
+ case DROP_PARTITION:
+ return getDropPartitionMessage(messageBody);
+ case CREATE_FUNCTION:
+ return getCreateFunctionMessage(messageBody);
+ case DROP_FUNCTION:
+ return getDropFunctionMessage(messageBody);
+ case CREATE_INDEX:
+ return getCreateIndexMessage(messageBody);
+ case DROP_INDEX:
+ return getDropIndexMessage(messageBody);
+ case ALTER_INDEX:
+ return getAlterIndexMessage(messageBody);
+ case INSERT:
+ return getInsertMessage(messageBody);
+ case ADD_PRIMARYKEY:
+ return getAddPrimaryKeyMessage(messageBody);
+ case ADD_FOREIGNKEY:
+ return getAddForeignKeyMessage(messageBody);
+ case ADD_UNIQUECONSTRAINT:
+ return getAddUniqueConstraintMessage(messageBody);
+ case ADD_NOTNULLCONSTRAINT:
+ return getAddNotNullConstraintMessage(messageBody);
+ case DROP_CONSTRAINT:
+ return getDropConstraintMessage(messageBody);
+ default:
+ throw new IllegalArgumentException("Unsupported event-type: " + eventTypeString);
+ }
+ }
+
+ /**
+ * Method to de-serialize CreateDatabaseMessage instance.
+ */
+ public abstract CreateDatabaseMessage getCreateDatabaseMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropDatabaseMessage instance.
+ */
+ public abstract DropDatabaseMessage getDropDatabaseMessage(String messageBody);
+
+ /**
+ * Method to de-serialize CreateTableMessage instance.
+ */
+ public abstract CreateTableMessage getCreateTableMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AlterTableMessge
+ * @param messageBody string message
+ * @return object message
+ */
+ public abstract AlterTableMessage getAlterTableMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropTableMessage instance.
+ */
+ public abstract DropTableMessage getDropTableMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AddPartitionMessage instance.
+ */
+ public abstract AddPartitionMessage getAddPartitionMessage(String messageBody);
+
+ /**
+ * Method to deserialize AlterPartitionMessage
+ * @param messageBody the message in serialized form
+ * @return message in object form
+ */
+ public abstract AlterPartitionMessage getAlterPartitionMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropPartitionMessage instance.
+ */
+ public abstract DropPartitionMessage getDropPartitionMessage(String messageBody);
+
+ /**
+ * Method to de-serialize CreateFunctionMessage instance.
+ */
+ public abstract CreateFunctionMessage getCreateFunctionMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropFunctionMessage instance.
+ */
+ public abstract DropFunctionMessage getDropFunctionMessage(String messageBody);
+
+ /**
+ * Method to de-serialize CreateIndexMessage instance.
+ */
+ public abstract CreateIndexMessage getCreateIndexMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropIndexMessage instance.
+ */
+ public abstract DropIndexMessage getDropIndexMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AlterIndexMessage instance.
+ */
+ public abstract AlterIndexMessage getAlterIndexMessage(String messageBody);
+
+ /**
+ * Method to deserialize InsertMessage
+ * @param messageBody the message in serialized form
+ * @return message in object form
+ */
+ public abstract InsertMessage getInsertMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AddPrimaryKeyMessage instance.
+ */
+ public abstract AddPrimaryKeyMessage getAddPrimaryKeyMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AddForeignKeyMessage instance.
+ */
+ public abstract AddForeignKeyMessage getAddForeignKeyMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AddUniqueConstraintMessage instance.
+ */
+ public abstract AddUniqueConstraintMessage getAddUniqueConstraintMessage(String messageBody);
+
+ /**
+ * Method to de-serialize AddNotNullConstraintMessage instance.
+ */
+ public abstract AddNotNullConstraintMessage getAddNotNullConstraintMessage(String messageBody);
+
+ /**
+ * Method to de-serialize DropConstraintMessage instance.
+ */
+ public abstract DropConstraintMessage getDropConstraintMessage(String messageBody);
+
+ // Protection against construction.
+ protected MessageDeserializer() {}
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
new file mode 100644
index 0000000..46fd336
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
@@ -0,0 +1,289 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.Index;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
+import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
+import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
+import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.utils.JavaUtils;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Abstract Factory for the construction of HCatalog message instances.
+ */
+public abstract class MessageFactory {
+
+ // Common name constants for event messages
+ public static final String ADD_PARTITION_EVENT = "ADD_PARTITION";
+ public static final String ALTER_PARTITION_EVENT = "ALTER_PARTITION";
+ public static final String DROP_PARTITION_EVENT = "DROP_PARTITION";
+ public static final String CREATE_TABLE_EVENT = "CREATE_TABLE";
+ public static final String ALTER_TABLE_EVENT = "ALTER_TABLE";
+ public static final String DROP_TABLE_EVENT = "DROP_TABLE";
+ public static final String CREATE_DATABASE_EVENT = "CREATE_DATABASE";
+ public static final String DROP_DATABASE_EVENT = "DROP_DATABASE";
+ public static final String INSERT_EVENT = "INSERT";
+ public static final String CREATE_FUNCTION_EVENT = "CREATE_FUNCTION";
+ public static final String DROP_FUNCTION_EVENT = "DROP_FUNCTION";
+ public static final String CREATE_INDEX_EVENT = "CREATE_INDEX";
+ public static final String DROP_INDEX_EVENT = "DROP_INDEX";
+ public static final String ALTER_INDEX_EVENT = "ALTER_INDEX";
+ public static final String ADD_PRIMARYKEY_EVENT = "ADD_PRIMARYKEY";
+ public static final String ADD_FOREIGNKEY_EVENT = "ADD_FOREIGNKEY";
+ public static final String ADD_UNIQUECONSTRAINT_EVENT = "ADD_UNIQUECONSTRAINT";
+ public static final String ADD_NOTNULLCONSTRAINT_EVENT = "ADD_NOTNULLCONSTRAINT";
+ public static final String DROP_CONSTRAINT_EVENT = "DROP_CONSTRAINT";
+
+ private static MessageFactory instance = null;
+
+ protected static final Configuration conf = MetastoreConf.newMetastoreConf();
+ /*
+ // TODO MS-SPLIT I'm 99% certain we don't need this, as MetastoreConf.newMetastoreConf already
+ adds this resource.
+ static {
+ conf.addResource("hive-site.xml");
+ }
+ */
+
+ protected static final String MS_SERVER_URL = MetastoreConf.getVar(conf, ConfVars.THRIFT_URIS, "");
+ protected static final String MS_SERVICE_PRINCIPAL =
+ MetastoreConf.getVar(conf, ConfVars.KERBEROS_PRINCIPAL, "");
+
+ /**
+ * Getter for MessageFactory instance.
+ */
+ public static MessageFactory getInstance() {
+ if (instance == null) {
+ instance =
+ getInstance(MetastoreConf.getVar(conf, ConfVars.EVENT_MESSAGE_FACTORY));
+ }
+ return instance;
+ }
+
+ private static MessageFactory getInstance(String className) {
+ try {
+ return JavaUtils.newInstance(JavaUtils.getClass(className, MessageFactory.class));
+ }
+ catch (MetaException e) {
+ throw new IllegalStateException("Could not construct MessageFactory implementation: ", e);
+ }
+ }
+
+ /**
+ * Getter for MessageDeserializer, corresponding to the specified format and version.
+ * @param format Serialization format for notifications.
+ * @param version Version of serialization format (currently ignored.)
+ * @return MessageDeserializer.
+ */
+ public static MessageDeserializer getDeserializer(String format,
+ String version) {
+ return getInstance(MetastoreConf.getVar(conf, ConfVars.EVENT_MESSAGE_FACTORY)).getDeserializer();
+ // Note : The reason this method exists outside the no-arg getDeserializer method is in
+ // case there is a user-implemented MessageFactory that's used, and some the messages
+ // are in an older format and the rest in another. Then, what MessageFactory is default
+ // is irrelevant, we should always use the one that was used to create it to deserialize.
+ //
+ // There exist only 2 implementations of this - json and jms
+ //
+ // Additional note : rather than as a config parameter, does it make sense to have
+ // this use jdbc-like semantics that each MessageFactory made available register
+ // itself for discoverability? Might be worth pursuing.
+ }
+
+ public abstract MessageDeserializer getDeserializer();
+
+ /**
+ * Getter for message-format.
+ */
+ public abstract String getMessageFormat();
+
+ /**
+ * Factory method for CreateDatabaseMessage.
+ * @param db The Database being added.
+ * @return CreateDatabaseMessage instance.
+ */
+ public abstract CreateDatabaseMessage buildCreateDatabaseMessage(Database db);
+
+ /**
+ * Factory method for DropDatabaseMessage.
+ * @param db The Database being dropped.
+ * @return DropDatabaseMessage instance.
+ */
+ public abstract DropDatabaseMessage buildDropDatabaseMessage(Database db);
+
+ /**
+ * Factory method for CreateTableMessage.
+ * @param table The Table being created.
+ * @param files Iterator of files
+ * @return CreateTableMessage instance.
+ */
+ public abstract CreateTableMessage buildCreateTableMessage(Table table, Iterator<String> files);
+
+ /**
+ * Factory method for AlterTableMessage. Unlike most of these calls, this one can return null,
+ * which means no message should be sent. This is because there are many flavors of alter
+ * table (add column, add partition, etc.). Some are covered elsewhere (like add partition)
+ * and some are not yet supported.
+ * @param before The table before the alter
+ * @param after The table after the alter
+ * @param isTruncateOp Flag to denote truncate table
+ * @return
+ */
+ public abstract AlterTableMessage buildAlterTableMessage(Table before, Table after, boolean isTruncateOp);
+
+ /**
+ * Factory method for DropTableMessage.
+ * @param table The Table being dropped.
+ * @return DropTableMessage instance.
+ */
+ public abstract DropTableMessage buildDropTableMessage(Table table);
+
+ /**
+ * Factory method for AddPartitionMessage.
+ * @param table The Table to which the partitions are added.
+ * @param partitions The iterator to set of Partitions being added.
+ * @param partitionFiles The iterator of partition files
+ * @return AddPartitionMessage instance.
+ */
+ public abstract AddPartitionMessage buildAddPartitionMessage(Table table, Iterator<Partition> partitions,
+ Iterator<PartitionFiles> partitionFiles);
+
+ /**
+ * Factory method for building AlterPartitionMessage
+ * @param table The table in which the partition is being altered
+ * @param before The partition before it was altered
+ * @param after The partition after it was altered
+ * @param isTruncateOp Flag to denote truncate partition
+ * @return a new AlterPartitionMessage
+ */
+ public abstract AlterPartitionMessage buildAlterPartitionMessage(Table table, Partition before,
+ Partition after, boolean isTruncateOp);
+
+ /**
+ * Factory method for DropPartitionMessage.
+ * @param table The Table from which the partition is dropped.
+ * @param partitions The set of partitions being dropped.
+ * @return DropPartitionMessage instance.
+ */
+ public abstract DropPartitionMessage buildDropPartitionMessage(Table table, Iterator<Partition> partitions);
+
+ /**
+ * Factory method for CreateFunctionMessage.
+ * @param fn The Function being added.
+ * @return CreateFunctionMessage instance.
+ */
+ public abstract CreateFunctionMessage buildCreateFunctionMessage(Function fn);
+
+ /**
+ * Factory method for DropFunctionMessage.
+ * @param fn The Function being dropped.
+ * @return DropFunctionMessage instance.
+ */
+ public abstract DropFunctionMessage buildDropFunctionMessage(Function fn);
+
+ /**
+ * Factory method for CreateIndexMessage.
+ * @param idx The Index being added.
+ * @return CreateIndexMessage instance.
+ */
+ public abstract CreateIndexMessage buildCreateIndexMessage(Index idx);
+
+ /**
+ * Factory method for DropIndexMessage.
+ * @param idx The Index being dropped.
+ * @return DropIndexMessage instance.
+ */
+ public abstract DropIndexMessage buildDropIndexMessage(Index idx);
+
+ /**
+ * Factory method for AlterIndexMessage.
+ * @param before The index before the alter
+ * @param after The index after the alter
+ * @return AlterIndexMessage
+ */
+ public abstract AlterIndexMessage buildAlterIndexMessage(Index before, Index after);
+
+ /**
+ * Factory method for building insert message
+ *
+ * @param tableObj Table object where the insert occurred in
+ * @param ptnObj Partition object where the insert occurred in, may be null if
+ * the insert was done into a non-partitioned table
+ * @param replace Flag to represent if INSERT OVERWRITE or INSERT INTO
+ * @param files Iterator of file created
+ * @return instance of InsertMessage
+ */
+ public abstract InsertMessage buildInsertMessage(Table tableObj, Partition ptnObj,
+ boolean replace, Iterator<String> files);
+
+ /***
+ * Factory method for building add primary key message
+ *
+ * @param pks list of primary keys
+ * @return instance of AddPrimaryKeyMessage
+ */
+ public abstract AddPrimaryKeyMessage buildAddPrimaryKeyMessage(List<SQLPrimaryKey> pks);
+
+ /***
+ * Factory method for building add foreign key message
+ *
+ * @param fks list of foreign keys
+ * @return instance of AddForeignKeyMessage
+ */
+ public abstract AddForeignKeyMessage buildAddForeignKeyMessage(List<SQLForeignKey> fks);
+
+ /***
+ * Factory method for building add unique constraint message
+ *
+ * @param uks list of unique constraints
+ * @return instance of SQLUniqueConstraint
+ */
+ public abstract AddUniqueConstraintMessage buildAddUniqueConstraintMessage(List<SQLUniqueConstraint> uks);
+
+ /***
+ * Factory method for building add not null constraint message
+ *
+ * @param nns list of not null constraints
+ * @return instance of SQLNotNullConstraint
+ */
+ public abstract AddNotNullConstraintMessage buildAddNotNullConstraintMessage(List<SQLNotNullConstraint> nns);
+
+ /***
+ * Factory method for building drop constraint message
+ * @param dbName
+ * @param tableName
+ * @param constraintName
+ * @return
+ */
+ public abstract DropConstraintMessage buildDropConstraintMessage(String dbName, String tableName,
+ String constraintName);
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java
new file mode 100644
index 0000000..308eaf1
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java
@@ -0,0 +1,53 @@
+/*
+ * 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.hadoop.hive.metastore.messaging;
+
+import java.util.Iterator;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class PartitionFiles {
+
+ @JsonProperty
+ private String partitionName;
+ @JsonProperty
+ private List<String> files;
+
+ public PartitionFiles(String partitionName, Iterator<String> files) {
+ this.partitionName = partitionName;
+ this.files = Lists.newArrayList(files);
+ }
+
+ public PartitionFiles() {
+ }
+
+ public String getPartitionName() {
+ return partitionName;
+ }
+
+ public void setPartitionName(String partitionName) {
+ this.partitionName = partitionName;
+ }
+
+ public Iterable<String> getFiles() {
+ return files;
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
new file mode 100644
index 0000000..9c912bf
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
@@ -0,0 +1,101 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
+import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * JSON implementation of AddForeignKeyMessage
+ */
+public class JSONAddForeignKeyMessage extends AddForeignKeyMessage {
+
+ @JsonProperty
+ String server, servicePrincipal;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ List<String> foreignKeyListJson;
+
+ /**
+ * Default constructor, needed for Jackson.
+ */
+ public JSONAddForeignKeyMessage() {
+ }
+
+ public JSONAddForeignKeyMessage(String server, String servicePrincipal, List<SQLForeignKey> fks,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.timestamp = timestamp;
+ this.foreignKeyListJson = new ArrayList<>();
+ try {
+ for (SQLForeignKey pk : fks) {
+ foreignKeyListJson.add(JSONMessageFactory.createForeignKeyObjJson(pk));
+ }
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return null;
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public List<SQLForeignKey> getForeignKeys() throws Exception {
+ List<SQLForeignKey> fks = new ArrayList<>();
+ for (String pkJson : foreignKeyListJson) {
+ fks.add((SQLForeignKey)JSONMessageFactory.getTObj(pkJson, SQLForeignKey.class));
+ }
+ return fks;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
new file mode 100644
index 0000000..79312e4
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
@@ -0,0 +1,96 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
+import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class JSONAddNotNullConstraintMessage extends AddNotNullConstraintMessage {
+ @JsonProperty
+ String server, servicePrincipal;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ List<String> notNullConstraintListJson;
+
+ /**
+ * Default constructor, needed for Jackson.
+ */
+ public JSONAddNotNullConstraintMessage() {
+ }
+
+ public JSONAddNotNullConstraintMessage(String server, String servicePrincipal, List<SQLNotNullConstraint> nns,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.timestamp = timestamp;
+ this.notNullConstraintListJson = new ArrayList<>();
+ try {
+ for (SQLNotNullConstraint nn : nns) {
+ notNullConstraintListJson.add(JSONMessageFactory.createNotNullConstraintObjJson(nn));
+ }
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return null;
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public List<SQLNotNullConstraint> getNotNullConstraints() throws Exception {
+ List<SQLNotNullConstraint> nns = new ArrayList<>();
+ for (String nnJson : notNullConstraintListJson) {
+ nns.add((SQLNotNullConstraint)JSONMessageFactory.getTObj(nnJson, SQLNotNullConstraint.class));
+ }
+ return nns;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
new file mode 100644
index 0000000..c232cce
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
@@ -0,0 +1,171 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.PartitionFiles;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JSON implementation of AddPartitionMessage.
+ */
+public class JSONAddPartitionMessage extends AddPartitionMessage {
+
+ @JsonProperty
+ String server, servicePrincipal, db, table, tableType, tableObjJson;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ List<Map<String, String>> partitions;
+
+ @JsonProperty
+ List<String> partitionListJson;
+
+ @JsonProperty
+ List<PartitionFiles> partitionFiles;
+
+ /**
+ * Default Constructor. Required for Jackson.
+ */
+ public JSONAddPartitionMessage() {
+ }
+
+ /**
+ * Note that we get an Iterator rather than an Iterable here: so we can only walk thru the list once
+ */
+ public JSONAddPartitionMessage(String server, String servicePrincipal, Table tableObj,
+ Iterator<Partition> partitionsIterator, Iterator<PartitionFiles> partitionFileIter,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.db = tableObj.getDbName();
+ this.table = tableObj.getTableName();
+ this.tableType = tableObj.getTableType();
+ this.timestamp = timestamp;
+ partitions = new ArrayList<>();
+ partitionListJson = new ArrayList<>();
+ Partition partitionObj;
+ try {
+ this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+ while (partitionsIterator.hasNext()) {
+ partitionObj = partitionsIterator.next();
+ partitions.add(JSONMessageFactory.getPartitionKeyValues(tableObj, partitionObj));
+ partitionListJson.add(JSONMessageFactory.createPartitionObjJson(partitionObj));
+ }
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ this.partitionFiles = Lists.newArrayList(partitionFileIter);
+ checkValid();
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return db;
+ }
+
+ @Override
+ public String getTable() {
+ return table;
+ }
+
+ @Override
+ public String getTableType() {
+ if (tableType != null) return tableType; else return "";
+ }
+
+ @Override
+ public Table getTableObj() throws Exception {
+ return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public List<Map<String, String>> getPartitions() {
+ return partitions;
+ }
+
+ @Override
+ public Iterable<Partition> getPartitionObjs() throws Exception {
+ // glorified cast from Iterable<TBase> to Iterable<Partition>
+ return Iterables.transform(
+ JSONMessageFactory.getTObjs(partitionListJson,Partition.class),
+ new Function<Object, Partition>() {
+ @Nullable
+ @Override
+ public Partition apply(@Nullable Object input) {
+ return (Partition) input;
+ }
+ });
+ }
+
+ public String getTableObjJson() {
+ return tableObjJson;
+ }
+
+ public List<String> getPartitionListJson() {
+ return partitionListJson;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+
+ @Override
+ public Iterable<PartitionFiles> getPartitionFilesIter() {
+ return partitionFiles;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
new file mode 100644
index 0000000..f4f4d5d
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
@@ -0,0 +1,101 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
+import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * JSON implementation of AddPrimaryKeyMessage
+ */
+public class JSONAddPrimaryKeyMessage extends AddPrimaryKeyMessage {
+
+ @JsonProperty
+ String server, servicePrincipal;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ List<String> primaryKeyListJson;
+
+ /**
+ * Default constructor, needed for Jackson.
+ */
+ public JSONAddPrimaryKeyMessage() {
+ }
+
+ public JSONAddPrimaryKeyMessage(String server, String servicePrincipal, List<SQLPrimaryKey> pks,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.timestamp = timestamp;
+ this.primaryKeyListJson = new ArrayList<>();
+ try {
+ for (SQLPrimaryKey pk : pks) {
+ primaryKeyListJson.add(JSONMessageFactory.createPrimaryKeyObjJson(pk));
+ }
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return null;
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public List<SQLPrimaryKey> getPrimaryKeys() throws Exception {
+ List<SQLPrimaryKey> pks = new ArrayList<>();
+ for (String pkJson : primaryKeyListJson) {
+ pks.add((SQLPrimaryKey)JSONMessageFactory.getTObj(pkJson, SQLPrimaryKey.class));
+ }
+ return pks;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
new file mode 100644
index 0000000..5a3cf96
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
@@ -0,0 +1,98 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
+import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class JSONAddUniqueConstraintMessage extends AddUniqueConstraintMessage {
+ @JsonProperty
+ String server, servicePrincipal;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ List<String> uniqueConstraintListJson;
+
+ /**
+ * Default constructor, needed for Jackson.
+ */
+ public JSONAddUniqueConstraintMessage() {
+ }
+
+ public JSONAddUniqueConstraintMessage(String server, String servicePrincipal, List<SQLUniqueConstraint> uks,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.timestamp = timestamp;
+ this.uniqueConstraintListJson = new ArrayList<>();
+ try {
+ for (SQLUniqueConstraint uk : uks) {
+ uniqueConstraintListJson.add(JSONMessageFactory.createUniqueConstraintObjJson(uk));
+ }
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return null;
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public List<SQLUniqueConstraint> getUniqueConstraints() throws Exception {
+ List<SQLUniqueConstraint> uks = new ArrayList<>();
+ for (String pkJson : uniqueConstraintListJson) {
+ uks.add((SQLUniqueConstraint)JSONMessageFactory.getTObj(pkJson, SQLUniqueConstraint.class));
+ }
+ return uks;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java
new file mode 100644
index 0000000..d1657b4
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java
@@ -0,0 +1,98 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import org.apache.hadoop.hive.metastore.api.Index;
+import org.apache.hadoop.hive.metastore.messaging.AlterIndexMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * JSON Implementation of AlterIndexMessage.
+ */
+public class JSONAlterIndexMessage extends AlterIndexMessage {
+
+ @JsonProperty
+ String server, servicePrincipal, db, beforeIndexObjJson, afterIndexObjJson;
+
+ @JsonProperty
+ Long timestamp;
+
+ /**
+ * Default constructor, required for Jackson.
+ */
+ public JSONAlterIndexMessage() {}
+
+ public JSONAlterIndexMessage(String server, String servicePrincipal, Index before, Index after,
+ Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.db = after.getDbName();
+ this.timestamp = timestamp;
+ try {
+ this.beforeIndexObjJson = JSONMessageFactory.createIndexObjJson(before);
+ this.afterIndexObjJson = JSONMessageFactory.createIndexObjJson(after);
+ } catch (TException ex) {
+ throw new IllegalArgumentException("Could not serialize Index object", ex);
+ }
+
+ checkValid();
+ }
+
+ @Override
+ public String getDB() { return db; }
+
+ @Override
+ public String getServer() { return server; }
+
+ @Override
+ public String getServicePrincipal() { return servicePrincipal; }
+
+ @Override
+ public Long getTimestamp() { return timestamp; }
+
+ public String getBeforeIndexObjJson() {
+ return beforeIndexObjJson;
+ }
+
+ public String getAfterIndexObjJson() {
+ return afterIndexObjJson;
+ }
+
+ @Override
+ public Index getIndexObjBefore() throws Exception {
+ return (Index) JSONMessageFactory.getTObj(beforeIndexObjJson, Index.class);
+ }
+
+ @Override
+ public Index getIndexObjAfter() throws Exception {
+ return (Index) JSONMessageFactory.getTObj(afterIndexObjJson, Index.class);
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ }
+ catch (Exception exception) {
+ throw new IllegalArgumentException("Could not serialize: ", exception);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/c5a9673a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
new file mode 100644
index 0000000..68cbd95
--- /dev/null
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
@@ -0,0 +1,148 @@
+/*
+ * 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.hadoop.hive.metastore.messaging.json;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
+import org.apache.thrift.TException;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Map;
+
+/**
+ * JSON alter table message
+ */
+public class JSONAlterPartitionMessage extends AlterPartitionMessage {
+
+ @JsonProperty
+ String server, servicePrincipal, db, table, tableType, tableObjJson;
+
+ @JsonProperty
+ String isTruncateOp;
+
+ @JsonProperty
+ Long timestamp;
+
+ @JsonProperty
+ Map<String, String> keyValues;
+
+ @JsonProperty
+ String partitionObjBeforeJson, partitionObjAfterJson;
+
+ /**
+ * Default constructor, needed for Jackson.
+ */
+ public JSONAlterPartitionMessage() {
+ }
+
+ public JSONAlterPartitionMessage(String server, String servicePrincipal, Table tableObj,
+ Partition partitionObjBefore, Partition partitionObjAfter, boolean isTruncateOp, Long timestamp) {
+ this.server = server;
+ this.servicePrincipal = servicePrincipal;
+ this.db = tableObj.getDbName();
+ this.table = tableObj.getTableName();
+ this.tableType = tableObj.getTableType();
+ this.isTruncateOp = Boolean.toString(isTruncateOp);
+ this.timestamp = timestamp;
+ this.keyValues = JSONMessageFactory.getPartitionKeyValues(tableObj, partitionObjBefore);
+ try {
+ this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+ this.partitionObjBeforeJson = JSONMessageFactory.createPartitionObjJson(partitionObjBefore);
+ this.partitionObjAfterJson = JSONMessageFactory.createPartitionObjJson(partitionObjAfter);
+ } catch (TException e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ checkValid();
+ }
+
+ @Override
+ public String getServer() {
+ return server;
+ }
+
+ @Override
+ public String getServicePrincipal() {
+ return servicePrincipal;
+ }
+
+ @Override
+ public String getDB() {
+ return db;
+ }
+
+ @Override
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public String getTable() {
+ return table;
+ }
+
+ @Override
+ public String getTableType() {
+ if (tableType != null) return tableType; else return "";
+ }
+
+ @Override
+ public boolean getIsTruncateOp() { return Boolean.parseBoolean(isTruncateOp); }
+
+ @Override
+ public Map<String, String> getKeyValues() {
+ return keyValues;
+ }
+
+ @Override
+ public Table getTableObj() throws Exception {
+ return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+ }
+
+ @Override
+ public Partition getPtnObjBefore() throws Exception {
+ return (Partition) JSONMessageFactory.getTObj(partitionObjBeforeJson, Partition.class);
+ }
+
+ @Override
+ public Partition getPtnObjAfter() throws Exception {
+ return (Partition) JSONMessageFactory.getTObj(partitionObjAfterJson, Partition.class);
+ }
+
+ public String getTableObjJson() {
+ return tableObjJson;
+ }
+
+ public String getPartitionObjBeforeJson() {
+ return partitionObjBeforeJson;
+ }
+
+ public String getPartitionObjAfterJson() {
+ return partitionObjAfterJson;
+ }
+
+ @Override
+ public String toString() {
+ try {
+ return JSONMessageDeserializer.mapper.writeValueAsString(this);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Could not serialize: ", e);
+ }
+ }
+}