http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java deleted file mode 100644 index d529147..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hive.metastore.api.Catalog; -import org.apache.hadoop.hive.metastore.api.Database; -import org.apache.hadoop.hive.metastore.api.Function; -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.api.TxnToWriteId; -import org.apache.hadoop.hive.metastore.conf.MetastoreConf; -import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; -import org.apache.hadoop.hive.metastore.events.AcidWriteEvent; -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 ALTER_DATABASE_EVENT = "ALTER_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 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"; - public static final String CREATE_ISCHEMA_EVENT = "CREATE_ISCHEMA"; - public static final String ALTER_ISCHEMA_EVENT = "ALTER_ISCHEMA"; - public static final String DROP_ISCHEMA_EVENT = "DROP_ISCHEMA"; - public static final String ADD_SCHEMA_VERSION_EVENT = "ADD_SCHEMA_VERSION"; - public static final String ALTER_SCHEMA_VERSION_EVENT = "ALTER_SCHEMA_VERSION"; - public static final String DROP_SCHEMA_VERSION_EVENT = "DROP_SCHEMA_VERSION"; - public static final String CREATE_CATALOG_EVENT = "CREATE_CATALOG"; - public static final String DROP_CATALOG_EVENT = "DROP_CATALOG"; - public static final String OPEN_TXN_EVENT = "OPEN_TXN"; - public static final String COMMIT_TXN_EVENT = "COMMIT_TXN"; - public static final String ABORT_TXN_EVENT = "ABORT_TXN"; - public static final String ALLOC_WRITE_ID_EVENT = "ALLOC_WRITE_ID_EVENT"; - public static final String ALTER_CATALOG_EVENT = "ALTER_CATALOG"; - public static final String ACID_WRITE_EVENT = "ACID_WRITE_EVENT"; - - 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 AlterDatabaseMessage. - * @param beforeDb The Database before alter. - * @param afterDb The Database after alter. - * @return AlterDatabaseMessage instance. - */ - public abstract AlterDatabaseMessage buildAlterDatabaseMessage(Database beforeDb, Database afterDb); - - /** - * 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 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 open txn message using start and end transaction range - * - * @param fromTxnId start transaction id (inclusive) - * @param toTxnId end transaction id (inclusive) - * @return instance of OpenTxnMessage - */ - public abstract OpenTxnMessage buildOpenTxnMessage(Long fromTxnId, Long toTxnId); - - /** - * Factory method for building commit txn message - * - * @param txnId Id of the transaction to be committed - * @return instance of CommitTxnMessage - */ - public abstract CommitTxnMessage buildCommitTxnMessage(Long txnId); - - /** - * Factory method for building abort txn message - * - * @param txnId Id of the transaction to be aborted - * @return instance of AbortTxnMessage - */ - public abstract AbortTxnMessage buildAbortTxnMessage(Long txnId); - - /** - * Factory method for building alloc write id message - * - * @param txnToWriteIdList List of Txn Ids and write id map - * @param dbName db for which write ids to be allocated - * @param tableName table for which write ids to be allocated - * @return instance of AllocWriteIdMessage - */ - public abstract AllocWriteIdMessage buildAllocWriteIdMessage(List<TxnToWriteId> txnToWriteIdList, String dbName, - String tableName); - - /*** - * 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); - - public abstract CreateCatalogMessage buildCreateCatalogMessage(Catalog catalog); - - public abstract DropCatalogMessage buildDropCatalogMessage(Catalog catalog); - - public abstract AlterCatalogMessage buildAlterCatalogMessage(Catalog oldCat, Catalog newCat); - - /** - * Factory method for building acid write message - * - * - * @param acidWriteEvent information related to the acid write operation - * @param files files added by this write operation - * @return instance of AcidWriteMessage - */ - public abstract AcidWriteMessage buildAcidWriteMessage(AcidWriteEvent acidWriteEvent, Iterator<String> files); -}
http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/OpenTxnMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/OpenTxnMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/OpenTxnMessage.java deleted file mode 100644 index 491344f..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/OpenTxnMessage.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging; - -import java.util.List; - -/** - * HCat message sent when an open transaction is done. - */ -public abstract class OpenTxnMessage extends EventMessage { - - protected OpenTxnMessage() { - super(EventType.OPEN_TXN); - } - - /** - * Get the list of txns opened - * @return The lists of TxnIds - */ - public abstract List<Long> getTxnIds(); -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java deleted file mode 100644 index 56a53e0..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/PartitionFiles.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hadoop.hive.metastore.messaging; - -import java.util.Iterator; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.collect.Lists; - -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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/AndFilter.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/AndFilter.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/AndFilter.java deleted file mode 100644 index 454d2cc..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/AndFilter.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.event.filters; - -import org.apache.hadoop.hive.metastore.IMetaStoreClient; -import org.apache.hadoop.hive.metastore.api.NotificationEvent; - -public class AndFilter implements IMetaStoreClient.NotificationFilter { - final IMetaStoreClient.NotificationFilter[] filters; - - public AndFilter(final IMetaStoreClient.NotificationFilter... filters) { - this.filters = filters; - } - - @Override - public boolean accept(final NotificationEvent event) { - for (IMetaStoreClient.NotificationFilter filter : filters) { - if (!filter.accept(event)) { - return false; - } - } - return true; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/BasicFilter.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/BasicFilter.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/BasicFilter.java deleted file mode 100644 index 84302d6..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/BasicFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.event.filters; - -import org.apache.hadoop.hive.metastore.IMetaStoreClient.NotificationFilter; -import org.apache.hadoop.hive.metastore.api.NotificationEvent; - -public abstract class BasicFilter implements NotificationFilter { - @Override - public boolean accept(final NotificationEvent event) { - if (event == null) { - return false; // get rid of trivial case first, so that we can safely assume non-null - } - return shouldAccept(event); - } - - abstract boolean shouldAccept(final NotificationEvent event); -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java deleted file mode 100644 index fdb6942..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.event.filters; - -import org.apache.hadoop.hive.metastore.api.NotificationEvent; -import org.apache.hadoop.hive.metastore.messaging.MessageFactory; - -import java.util.regex.Pattern; - -/** - * Utility function that constructs a notification filter to match a given db name and/or table name. - * If dbName == null, fetches all warehouse events. - * If dnName != null, but tableName == null, fetches all events for the db - * If dbName != null && tableName != null, fetches all events for the specified table - */ -public class DatabaseAndTableFilter extends BasicFilter { - private final String tableName; - private final Pattern dbPattern; - - public DatabaseAndTableFilter(final String databaseNameOrPattern, final String tableName) { - // we convert the databaseNameOrPattern to lower case because events will have these names in lower case. - this.dbPattern = (databaseNameOrPattern == null || databaseNameOrPattern.equals("*")) - ? null - : Pattern.compile(databaseNameOrPattern, Pattern.CASE_INSENSITIVE); - this.tableName = tableName; - } - - private boolean isTxnRelatedEvent(final NotificationEvent event) { - return ((event.getEventType().equals(MessageFactory.OPEN_TXN_EVENT)) || - (event.getEventType().equals(MessageFactory.COMMIT_TXN_EVENT)) || - (event.getEventType().equals(MessageFactory.ABORT_TXN_EVENT))); - } - - @Override - boolean shouldAccept(final NotificationEvent event) { - if ((dbPattern == null) || isTxnRelatedEvent(event)) { - return true; - } - if (dbPattern.matcher(event.getDbName()).matches()) { - if ((tableName == null) - // if our dbName is equal, but tableName is blank, we're interested in this db-level event - || (tableName.equalsIgnoreCase(event.getTableName())) - // table level event that matches us - ) { - return true; - } - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/EventBoundaryFilter.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/EventBoundaryFilter.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/EventBoundaryFilter.java deleted file mode 100644 index 988874d..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/EventBoundaryFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.event.filters; - -import org.apache.hadoop.hive.metastore.api.NotificationEvent; - -public class EventBoundaryFilter extends BasicFilter { - private final long eventFrom, eventTo; - - public EventBoundaryFilter(final long eventFrom, final long eventTo) { - this.eventFrom = eventFrom; - this.eventTo = eventTo; - } - - @Override - boolean shouldAccept(final NotificationEvent event) { - return eventFrom <= event.getEventId() && event.getEventId() <= eventTo; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/MessageFormatFilter.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/MessageFormatFilter.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/MessageFormatFilter.java deleted file mode 100644 index b0ce3b9..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/MessageFormatFilter.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.event.filters; - -import org.apache.hadoop.hive.metastore.api.NotificationEvent; - -public class MessageFormatFilter extends BasicFilter { - private final String format; - - public MessageFormatFilter(String format) { - this.format = format; - } - - @Override - boolean shouldAccept(final NotificationEvent event) { - if (format == null) { - return true; // let's say that passing null in will not do any filtering. - } - return format.equalsIgnoreCase(event.getMessageFormat()); - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAbortTxnMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAbortTxnMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAbortTxnMessage.java deleted file mode 100644 index 5da816b..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAbortTxnMessage.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; -import org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JSON implementation of AbortTxnMessage - */ -public class JSONAbortTxnMessage extends AbortTxnMessage { - - @JsonProperty - private Long txnid; - - @JsonProperty - private Long timestamp; - - @JsonProperty - private String server; - - @JsonProperty - private String servicePrincipal; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAbortTxnMessage() { - } - - public JSONAbortTxnMessage(String server, String servicePrincipal, Long txnid, Long timestamp) { - this.timestamp = timestamp; - this.txnid = txnid; - this.server = server; - this.servicePrincipal = servicePrincipal; - } - - @Override - public Long getTxnId() { - return txnid; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public String getDB() { - return null; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - @Override - public String getServer() { - return server; - } - - @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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java deleted file mode 100644 index cc528ee..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import com.fasterxml.jackson.annotation.JsonProperty; -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.events.AcidWriteEvent; -import org.apache.hadoop.hive.metastore.messaging.AcidWriteMessage; -import org.apache.thrift.TException; -import java.util.Iterator; -import java.util.List; - -/** - * JSON implementation of AcidWriteMessage - */ -public class JSONAcidWriteMessage extends AcidWriteMessage { - - @JsonProperty - private Long txnid, writeId, timestamp; - - @JsonProperty - private String server, servicePrincipal, database, table, partition, tableObjJson, partitionObjJson; - - @JsonProperty - private List<String> files; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAcidWriteMessage() { - } - - public JSONAcidWriteMessage(String server, String servicePrincipal, Long timestamp, AcidWriteEvent acidWriteEvent, - Iterator<String> files) { - this.timestamp = timestamp; - this.txnid = acidWriteEvent.getTxnId(); - this.server = server; - this.servicePrincipal = servicePrincipal; - this.database = acidWriteEvent.getDatabase(); - this.table = acidWriteEvent.getTable(); - this.writeId = acidWriteEvent.getWriteId(); - this.partition = acidWriteEvent.getPartition(); - try { - this.tableObjJson = JSONMessageFactory.createTableObjJson(acidWriteEvent.getTableObj()); - if (acidWriteEvent.getPartitionObj() != null) { - this.partitionObjJson = JSONMessageFactory.createPartitionObjJson(acidWriteEvent.getPartitionObj()); - } else { - this.partitionObjJson = null; - } - } catch (TException e) { - throw new IllegalArgumentException("Could not serialize JSONAcidWriteMessage : ", e); - } - this.files = Lists.newArrayList(files); - } - - @Override - public Long getTxnId() { - return txnid; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public String getDB() { - return database; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - @Override - public String getServer() { - return server; - } - - @Override - public String getTable() { - return table; - } - - @Override - public Long getWriteId() { - return writeId; - } - - @Override - public String getPartition() { - return partition; - } - - @Override - public List<String> getFiles() { - return files; - } - - @Override - public Table getTableObj() throws Exception { - return (tableObjJson == null) ? null : (Table) JSONMessageFactory.getTObj(tableObjJson, Table.class); - } - - @Override - public Partition getPartitionObj() throws Exception { - return ((partitionObjJson == null) ? null : - (Partition) JSONMessageFactory.getTObj(partitionObjJson, Partition.class)); - } - - @Override - public String getTableObjStr() { - return tableObjJson; - } - - @Override - public String getPartitionObjStr() { - return partitionObjJson; - } - - @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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java deleted file mode 100644 index d4a0bc2..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.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 com.fasterxml.jackson.annotation.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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java deleted file mode 100644 index 1c3e8a8..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.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 com.fasterxml.jackson.annotation.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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java deleted file mode 100644 index 11921f2..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; - -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 com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Function; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * 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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java deleted file mode 100644 index 3a18be8..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.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 com.fasterxml.jackson.annotation.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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java deleted file mode 100644 index 3c4d5e0..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.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 com.fasterxml.jackson.annotation.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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAllocWriteIdMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAllocWriteIdMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAllocWriteIdMessage.java deleted file mode 100644 index 33b24fe..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAllocWriteIdMessage.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.hive.metastore.api.TxnToWriteId; -import org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JSON implementation of AllocWriteId - */ -public class JSONAllocWriteIdMessage extends AllocWriteIdMessage { - - @JsonProperty - private String server, servicePrincipal, dbName, tableName; - - @JsonProperty - private List<Long> txnIdList, writeIdList; - - @JsonProperty - private Long timestamp; - - private List<TxnToWriteId> txnToWriteIdList; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAllocWriteIdMessage() { - } - - public JSONAllocWriteIdMessage(String server, String servicePrincipal, - List<TxnToWriteId> txnToWriteIdList, String dbName, String tableName, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.timestamp = timestamp; - this.txnIdList = new ArrayList<>(); - this.writeIdList = new ArrayList<>(); - for (TxnToWriteId txnToWriteId : txnToWriteIdList) { - this.txnIdList.add(txnToWriteId.getTxnId()); - this.writeIdList.add(txnToWriteId.getWriteId()); - } - this.tableName = tableName; - this.dbName = dbName; - this.txnToWriteIdList = txnToWriteIdList; - } - - @Override - public String getServer() { - return server; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - @Override - public String getDB() { - return dbName; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public String getTableName() { - return tableName; - } - - @Override - public List<TxnToWriteId> getTxnToWriteIdList() { - // after deserialization, need to recreate the txnToWriteIdList as its not under JsonProperty. - if (txnToWriteIdList == null) { - txnToWriteIdList = new ArrayList<>(); - for (int idx = 0; idx < txnIdList.size(); idx++) { - txnToWriteIdList.add(new TxnToWriteId(txnIdList.get(idx), writeIdList.get(idx))); - } - } - return txnToWriteIdList; - } - - @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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java deleted file mode 100644 index 779c0b0..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.fasterxml.jackson.annotation.JsonProperty; -import org.apache.hadoop.hive.metastore.api.Catalog; -import org.apache.hadoop.hive.metastore.messaging.AlterCatalogMessage; -import org.apache.thrift.TException; - -public class JSONAlterCatalogMessage extends AlterCatalogMessage { - @JsonProperty - String server, servicePrincipal, catObjBeforeJson, catObjAfterJson; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAlterCatalogMessage() { - } - - public JSONAlterCatalogMessage(String server, String servicePrincipal, - Catalog catObjBefore, Catalog catObjAfter, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.timestamp = timestamp; - try { - this.catObjBeforeJson = JSONMessageFactory.createCatalogObjJson(catObjBefore); - this.catObjAfterJson = JSONMessageFactory.createCatalogObjJson(catObjAfter); - } catch (TException e) { - throw new IllegalArgumentException("Could not serialize: ", e); - } - checkValid(); - } - - @Override - public String getDB() { - return null; - } - - @Override - public String getServer() { - return server; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public Catalog getCatObjBefore() throws Exception { - return (Catalog) JSONMessageFactory.getTObj(catObjBeforeJson, Catalog.class); - } - - @Override - public Catalog getCatObjAfter() throws Exception { - return (Catalog) JSONMessageFactory.getTObj(catObjAfterJson, Catalog.class); - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } catch (Exception e) { - throw new IllegalArgumentException("Could not serialize: ", e); - } - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java deleted file mode 100644 index 7b316d5..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.json; - -import org.apache.hadoop.hive.metastore.api.Database; -import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage; -import org.apache.thrift.TException; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JSON alter database message. - */ -public class JSONAlterDatabaseMessage extends AlterDatabaseMessage { - - @JsonProperty - String server, servicePrincipal, db, dbObjBeforeJson, dbObjAfterJson; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAlterDatabaseMessage() { - } - - public JSONAlterDatabaseMessage(String server, String servicePrincipal, - Database dbObjBefore, Database dbObjAfter, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.db = dbObjBefore.getName(); - this.timestamp = timestamp; - try { - this.dbObjBeforeJson = JSONMessageFactory.createDatabaseObjJson(dbObjBefore); - this.dbObjAfterJson = JSONMessageFactory.createDatabaseObjJson(dbObjAfter); - } 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 Database getDbObjBefore() throws Exception { - return (Database) JSONMessageFactory.getTObj(dbObjBeforeJson, Database.class); - } - - @Override - public Database getDbObjAfter() throws Exception { - return (Database) JSONMessageFactory.getTObj(dbObjAfterJson, Database.class); - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } catch (Exception e) { - throw new IllegalArgumentException("Could not serialize: ", e); - } - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java deleted file mode 100644 index 2ddec51..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.json; - -import java.util.Map; - -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 com.fasterxml.jackson.annotation.JsonProperty; - -/** - * 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); - } - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java deleted file mode 100644 index d398fa0..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hadoop.hive.metastore.messaging.json; - -import org.apache.hadoop.hive.metastore.api.Table; -import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage; -import org.apache.thrift.TException; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JSON alter table message - */ -public class JSONAlterTableMessage extends AlterTableMessage { - - @JsonProperty - String server, servicePrincipal, db, table, tableType, tableObjBeforeJson, tableObjAfterJson; - - @JsonProperty - String isTruncateOp; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, needed for Jackson. - */ - public JSONAlterTableMessage() { - } - - public JSONAlterTableMessage(String server, String servicePrincipal, Table tableObjBefore, Table tableObjAfter, - boolean isTruncateOp, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.db = tableObjBefore.getDbName(); - this.table = tableObjBefore.getTableName(); - this.tableType = tableObjBefore.getTableType(); - this.isTruncateOp = Boolean.toString(isTruncateOp); - this.timestamp = timestamp; - try { - this.tableObjBeforeJson = JSONMessageFactory.createTableObjJson(tableObjBefore); - this.tableObjAfterJson = JSONMessageFactory.createTableObjJson(tableObjAfter); - } 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 Table getTableObjBefore() throws Exception { - return (Table) JSONMessageFactory.getTObj(tableObjBeforeJson,Table.class); - } - - @Override - public Table getTableObjAfter() throws Exception { - return (Table) JSONMessageFactory.getTObj(tableObjAfterJson,Table.class); - } - - public String getTableObjBeforeJson() { - return tableObjBeforeJson; - } - - public String getTableObjAfterJson() { - return tableObjAfterJson ; - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } catch (Exception e) { - throw new IllegalArgumentException("Could not serialize: ", e); - } - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java deleted file mode 100644 index 2c4940b..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; -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.api.WriteEventInfo; -import org.apache.hadoop.hive.metastore.messaging.CommitTxnMessage; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * JSON implementation of CommitTxnMessage - */ -public class JSONCommitTxnMessage extends CommitTxnMessage { - - @JsonProperty - private Long txnid; - - @JsonProperty - private Long timestamp; - - @JsonProperty - private String server; - - @JsonProperty - private String servicePrincipal; - - @JsonProperty - private List<Long> writeIds; - - @JsonProperty - private List<String> databases, tables, partitions, tableObjs, partitionObjs, files; - - /** - * Default constructor, needed for Jackson. - */ - public JSONCommitTxnMessage() { - } - - public JSONCommitTxnMessage(String server, String servicePrincipal, Long txnid, Long timestamp) { - this.timestamp = timestamp; - this.txnid = txnid; - this.server = server; - this.servicePrincipal = servicePrincipal; - this.databases = null; - this.tables = null; - this.writeIds = null; - this.partitions = null; - this.tableObjs = null; - this.partitionObjs = null; - this.files = null; - } - - @Override - public Long getTxnId() { - return txnid; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public String getDB() { - return null; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - @Override - public String getServer() { - return server; - } - - @Override - public List<Long> getWriteIds() { - return writeIds; - } - - @Override - public List<String> getDatabases() { - return databases; - } - - @Override - public List<String> getTables() { - return tables; - } - - @Override - public List<String> getPartitions() { - return partitions; - } - - @Override - public Table getTableObj(int idx) throws Exception { - return tableObjs == null ? null : (Table) JSONMessageFactory.getTObj(tableObjs.get(idx), Table.class); - } - - @Override - public Partition getPartitionObj(int idx) throws Exception { - return (partitionObjs == null ? null : (partitionObjs.get(idx) == null ? null : - (Partition)JSONMessageFactory.getTObj(partitionObjs.get(idx), Partition.class))); - } - - @Override - public String getFiles(int idx) { - return files == null ? null : files.get(idx); - } - - @Override - public List<String> getFilesList() { - return files; - } - - @Override - public void addWriteEventInfo(List<WriteEventInfo> writeEventInfoList) { - if (this.databases == null) { - this.databases = Lists.newArrayList(); - } - if (this.tables == null) { - this.tables = Lists.newArrayList(); - } - if (this.writeIds == null) { - this.writeIds = Lists.newArrayList(); - } - if (this.tableObjs == null) { - this.tableObjs = Lists.newArrayList(); - } - if (this.partitions == null) { - this.partitions = Lists.newArrayList(); - } - if (this.partitionObjs == null) { - this.partitionObjs = Lists.newArrayList(); - } - if (this.files == null) { - this.files = Lists.newArrayList(); - } - - for (WriteEventInfo writeEventInfo : writeEventInfoList) { - this.databases.add(writeEventInfo.getDatabase()); - this.tables.add(writeEventInfo.getTable()); - this.writeIds.add(writeEventInfo.getWriteId()); - this.partitions.add(writeEventInfo.getPartition()); - this.tableObjs.add(writeEventInfo.getTableObj()); - this.partitionObjs.add(writeEventInfo.getPartitionObj()); - this.files.add(writeEventInfo.getFiles()); - } - } - - @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/081fa368/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateCatalogMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateCatalogMessage.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateCatalogMessage.java deleted file mode 100644 index e9038d0..0000000 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateCatalogMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.messaging.CreateCatalogMessage; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class JSONCreateCatalogMessage extends CreateCatalogMessage { - - @JsonProperty - String server, servicePrincipal, catalog; - - @JsonProperty - Long timestamp; - - /** - * Required for Jackson - */ - public JSONCreateCatalogMessage() { - - } - - public JSONCreateCatalogMessage(String server, String servicePrincipal, String catalog, - Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.catalog = catalog; - this.timestamp = timestamp; - } - - @Override - public String getDB() { - return null; - } - - @Override - public String getServer() { - return server; - } - - @Override - public String getServicePrincipal() { - return servicePrincipal; - } - - public String getCatalog() { - return catalog; - } - - @Override - public Long getTimestamp() { - return timestamp; - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not serialize: ", exception); - } - } -}