From d9739e02e0e32539736e426ae7e642c580cb6b22 Mon Sep 17 00:00:00 2001 From: Daniel del Castillo Date: Tue, 13 Mar 2018 11:47:08 +0000 Subject: [PATCH] [issue-47] Better replica-check exception message --- CHANGELOG.md | 4 ++++ .../core/replica/DestinationNotReplicaException.java | 12 +++++++++--- .../hotels/bdp/circustrain/core/replica/Replica.java | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 700468ed..441500da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# TBD +### Changed +* Clearer replica-check exception message. See [#47](https://github.com/HotelsDotCom/circus-train/issues/47). + # 11.3.0 - 2018-02-27 ### Changed * SNS message now indicates if message was truncated. See [#41](https://github.com/HotelsDotCom/circus-train/issues/41). diff --git a/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/DestinationNotReplicaException.java b/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/DestinationNotReplicaException.java index dc6fcf90..e7a382be 100644 --- a/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/DestinationNotReplicaException.java +++ b/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/DestinationNotReplicaException.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2016-2017 Expedia Inc. + * Copyright (C) 2016-2018 Expedia Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,23 @@ import org.apache.hadoop.hive.metastore.api.Table; import com.hotels.bdp.circustrain.api.CircusTrainException; +import com.hotels.bdp.circustrain.api.CircusTrainTableParameter; public class DestinationNotReplicaException extends CircusTrainException { private static final long serialVersionUID = 1L; - DestinationNotReplicaException(Table oldReplicaTable, String replicaMetastoreUris) { + DestinationNotReplicaException( + Table oldReplicaTable, + String replicaMetastoreUris, + CircusTrainTableParameter tableParameter) { super("Found an existing table '" + Warehouse.getQualifiedName(oldReplicaTable) + "' in '" + replicaMetastoreUris - + "', but it does not appear to be a replica!"); + + "', but it does not appear to be a replica! Missing table property '" + + tableParameter.parameterName() + + "'"); } } diff --git a/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/Replica.java b/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/Replica.java index 1ab78f50..98375f9c 100644 --- a/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/Replica.java +++ b/circus-train-core/src/main/java/com/hotels/bdp/circustrain/core/replica/Replica.java @@ -50,6 +50,7 @@ import com.hotels.bdp.circustrain.api.ReplicaLocationManager; import com.hotels.bdp.circustrain.api.SourceLocationManager; import com.hotels.bdp.circustrain.api.event.ReplicaCatalogListener; +import com.hotels.bdp.circustrain.api.listener.HousekeepingListener; import com.hotels.bdp.circustrain.api.metastore.CloseableMetaStoreClient; import com.hotels.bdp.circustrain.api.metastore.MetaStoreClientException; import com.hotels.bdp.circustrain.core.HiveEndpoint; @@ -60,7 +61,6 @@ import com.hotels.bdp.circustrain.core.conf.TableReplication; import com.hotels.bdp.circustrain.core.event.EventUtils; import com.hotels.bdp.circustrain.core.metastore.LocationUtils; -import com.hotels.bdp.circustrain.api.listener.HousekeepingListener; public class Replica extends HiveEndpoint { @@ -297,7 +297,8 @@ private void determinValidityOfReplica(ReplicationMode replicationMode, Table ol // REPLICATION_EVENT to determine if a table was created via CT. String previousEvent = oldReplicaTable.getParameters().get(REPLICATION_EVENT.parameterName()); if (StringUtils.isBlank(previousEvent)) { - throw new DestinationNotReplicaException(oldReplicaTable, getHiveConf().getVar(ConfVars.METASTOREURIS)); + throw new DestinationNotReplicaException(oldReplicaTable, getHiveConf().getVar(ConfVars.METASTOREURIS), + REPLICATION_EVENT); } LOG.debug("Checking that replication modes are compatible."); Optional replicaReplicationMode = Enums.getIfPresent(ReplicationMode.class,