Skip to content

Commit 7a09015

Browse files
committed
Changed return type of BasicAccumuloOperations.deleteAll()
1 parent 0494211 commit 7a09015

11 files changed

Lines changed: 187 additions & 42 deletions

File tree

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/AccumuloOperations.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package mil.nga.giat.geowave.accumulo;
22

3+
import java.io.IOException;
34
import java.util.List;
45

56
import mil.nga.giat.geowave.index.ByteArrayId;
@@ -220,14 +221,13 @@ public void addLocalityGroup(
220221
AccumuloSecurityException;
221222

222223
/**
223-
* Drops all tables in the given namespace. Returns whether any tables were
224-
* found and the operation completed successfully.
225-
*
226-
* @return Returns true if at least one table was found and dropped with the
227-
* given namespace, false if nothing was found or it was not dropped
228-
* successfully
224+
* Drops all tables in the instance namespace. If no tables are found in
225+
* the namespace no operation occurs.
229226
*/
230-
public boolean deleteAll();
227+
public void deleteAll()
228+
throws TableNotFoundException,
229+
AccumuloException,
230+
AccumuloSecurityException;
231231

232232
/**
233233
* Drops the specified row from the specified table. Returns whether the

geowave-accumulo/src/main/java/mil/nga/giat/geowave/accumulo/BasicAccumuloOperations.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,30 +309,28 @@ private String getQualifiedTableName(
309309
unqualifiedTableName);
310310
}
311311

312+
/**
313+
*
314+
*/
312315
@Override
313-
public boolean deleteAll() {
316+
public void deleteAll()
317+
throws AccumuloSecurityException,
318+
AccumuloException,
319+
TableNotFoundException {
314320
SortedSet<String> tableNames = connector.tableOperations().list();
315321

316322
if ((tableNamespace != null) && !tableNamespace.isEmpty()) {
317323
tableNames = tableNames.subSet(
318324
tableNamespace,
319325
tableNamespace + '\uffff');
320326
}
321-
boolean success = !tableNames.isEmpty();
327+
322328
for (final String tableName : tableNames) {
323-
try {
324329
connector.tableOperations().delete(
325330
tableName);
326331
}
327-
catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) {
328-
LOGGER.warn(
329-
"Unable to delete table '" + tableName + "'",
330-
e);
331-
success = false;
332-
}
333332
}
334-
return success;
335-
}
333+
336334

337335
@Override
338336
public boolean delete(

geowave-accumulo/src/test/java/mil/nga/giat/geowave/accumulo/AccumuloOptionsTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.accumulo.core.client.mock.MockInstance;
3737
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
3838
import org.apache.log4j.Logger;
39+
import org.junit.Assert;
3940
import org.junit.Before;
4041
import org.junit.Test;
4142

@@ -388,7 +389,13 @@ public void testAlternateIndexOption() {
388389

389390
accumuloOptions.setUseAltIndex(true);
390391

391-
accumuloOperations.deleteAll();
392+
try {
393+
accumuloOperations.deleteAll();
394+
}
395+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
396+
LOGGER.error("Unable to clear accumulo namespace", e);
397+
Assert.fail("Unable to clear accumulo namespace");
398+
}
392399

393400
mockDataStore.ingest(
394401
adapter,

geowave-benchmark/src/main/java/mil/nga/giat/geowave/benchmark/FeatureCollectionDataAdapterBenchmark.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ private void ingestFeatureData(
352352
final FeatureDataAdapter featureAdapter = new FeatureDataAdapter(
353353
TYPE);
354354
if (write) {
355-
featureOperations.deleteAll();
355+
try {
356+
featureOperations.deleteAll();
357+
}
358+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
359+
log.error("Unable to clear accumulo namespace", e);
360+
}
356361
}
357362
ingestData(
358363
IngestType.FEATURE_INGEST,
@@ -400,7 +405,13 @@ private void ingestCollectionData(
400405
TYPE,
401406
batchSize);
402407
if (write) {
403-
featureCollectionOperations.deleteAll();
408+
try {
409+
featureCollectionOperations.deleteAll();
410+
}
411+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
412+
log.error("Unable to clear accumulo namespace", e);
413+
}
414+
404415
}
405416
ingestData(
406417
IngestType.COLLECTION_INGEST,
@@ -1004,7 +1015,14 @@ private void cleanup()
10041015
username,
10051016
password,
10061017
featureNamespace);
1007-
featureOperations.deleteAll();
1018+
1019+
try {
1020+
featureOperations.deleteAll();
1021+
}
1022+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
1023+
log.error("Unable to clear accumulo namespace", e);
1024+
}
1025+
10081026

10091027
for (final int batchSize : pointsPerTile) {
10101028
final BasicAccumuloOperations featureCollectionOperations = new BasicAccumuloOperations(
@@ -1013,7 +1031,13 @@ private void cleanup()
10131031
username,
10141032
password,
10151033
featureCollectionNamespace + batchSize);
1016-
featureCollectionOperations.deleteAll();
1034+
try {
1035+
featureCollectionOperations.deleteAll();
1036+
}
1037+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
1038+
log.error("Unable to clear accumulo namespace", e);
1039+
}
1040+
10171041
}
10181042
}
10191043

geowave-ingest/src/main/java/mil/nga/giat/geowave/ingest/AccumuloCommandLineOptions.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.apache.accumulo.core.client.AccumuloException;
99
import org.apache.accumulo.core.client.AccumuloSecurityException;
10+
import org.apache.accumulo.core.client.TableNotFoundException;
1011
import org.apache.commons.cli.CommandLine;
1112
import org.apache.commons.cli.Option;
1213
import org.apache.commons.cli.Options;
@@ -64,7 +65,13 @@ protected void clearNamespace()
6465
// don't delete all tables in the case that no namespace is given
6566
if ((namespace != null) && !namespace.isEmpty()) {
6667
LOGGER.info("deleting all tables prefixed by '" + namespace + "'");
67-
getAccumuloOperations().deleteAll();
68+
try {
69+
getAccumuloOperations().deleteAll();
70+
}
71+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException e) {
72+
LOGGER.error("Unable to clear accumulo namespace");
73+
}
74+
6875
}
6976
else {
7077
LOGGER.error("cannot clear a namespace if no namespace is provided");

geowave-test/src/main/java/mil/nga/giat/geowave/test/GeoWaveTestEnvironment.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.lingala.zip4j.exception.ZipException;
2828
import org.apache.accumulo.core.client.AccumuloException;
2929
import org.apache.accumulo.core.client.AccumuloSecurityException;
30+
import org.apache.accumulo.core.client.TableNotFoundException;
3031
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
3132
import org.apache.accumulo.minicluster.MiniAccumuloConfig;
3233
import org.apache.commons.io.FileUtils;
@@ -188,9 +189,18 @@ protected static boolean isSet(
188189
public static void cleanup() {
189190
synchronized (MUTEX) {
190191
if (!DEFER_CLEANUP) {
191-
Assert.assertTrue(
192-
"Index not deleted successfully",
193-
(accumuloOperations == null) || accumuloOperations.deleteAll());
192+
193+
if (accumuloOperations == null){
194+
Assert.fail("Invalid state <null> for accumulo operations during CLEANUP phase");
195+
}
196+
try {
197+
accumuloOperations.deleteAll();
198+
}
199+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
200+
LOGGER.error("Unable to clear accumulo namespace", ex);
201+
Assert.fail("Index not deleted successfully");
202+
}
203+
194204
accumuloOperations = null;
195205
zookeeper = null;
196206
accumuloInstance = null;

geowave-test/src/test/java/mil/nga/giat/geowave/test/GeoWaveBasicIT.java

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import mil.nga.giat.geowave.store.index.IndexType;
1616
import mil.nga.giat.geowave.store.query.DistributableQuery;
1717

18+
import org.apache.accumulo.core.client.AccumuloException;
19+
import org.apache.accumulo.core.client.AccumuloSecurityException;
20+
import org.apache.accumulo.core.client.TableNotFoundException;
1821
import org.apache.commons.lang.StringUtils;
1922
import org.apache.log4j.Logger;
2023
import org.junit.Assert;
@@ -84,7 +87,13 @@ public void testIngestAndQuerySpatialPointsAndLines() {
8487
}
8588
catch (final Exception e) {
8689
e.printStackTrace();
87-
accumuloOperations.deleteAll();
90+
try {
91+
accumuloOperations.deleteAll();
92+
}
93+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
94+
LOGGER.error("Unable to clear accumulo namespace", ex);
95+
}
96+
8897
Assert.fail("Error occurred while testing a bounding box query of spatial index: '" + e.getLocalizedMessage() + "'");
8998
}
9099
try {
@@ -102,7 +111,12 @@ public void testIngestAndQuerySpatialPointsAndLines() {
102111
}
103112
catch (final Exception e) {
104113
e.printStackTrace();
105-
accumuloOperations.deleteAll();
114+
try {
115+
accumuloOperations.deleteAll();
116+
}
117+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
118+
LOGGER.error("Unable to clear accumulo namespace", ex);
119+
}
106120
Assert.fail("Error occurred while testing a polygon query of spatial index: '" + e.getLocalizedMessage() + "'");
107121
}
108122

@@ -114,10 +128,20 @@ public void testIngestAndQuerySpatialPointsAndLines() {
114128
}
115129
catch (final Exception e) {
116130
e.printStackTrace();
117-
accumuloOperations.deleteAll();
131+
try {
132+
accumuloOperations.deleteAll();
133+
}
134+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
135+
LOGGER.error("Unable to clear accumulo namespace", ex);
136+
}
118137
Assert.fail("Error occurred while testing deletion of an entry using spatial index: '" + e.getLocalizedMessage() + "'");
119138
}
120-
accumuloOperations.deleteAll();
139+
try {
140+
accumuloOperations.deleteAll();
141+
}
142+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
143+
LOGGER.error("Unable to clear accumulo namespace", ex);
144+
}
121145
}
122146

123147
@Test
@@ -143,7 +167,12 @@ public void testIngestAndQuerySpatialTemporalPointsAndLines() {
143167
}
144168
catch (final Exception e) {
145169
e.printStackTrace();
146-
accumuloOperations.deleteAll();
170+
try {
171+
accumuloOperations.deleteAll();
172+
}
173+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
174+
LOGGER.error("Unable to clear accumulo namespace", ex);
175+
}
147176
Assert.fail("Error occurred while testing a bounding box and time range query of spatial temporal index: '" + e.getLocalizedMessage() + "'");
148177
}
149178
try {
@@ -159,7 +188,12 @@ public void testIngestAndQuerySpatialTemporalPointsAndLines() {
159188
"polygon constraint and time range");
160189
}
161190
catch (final Exception e) {
162-
accumuloOperations.deleteAll();
191+
try {
192+
accumuloOperations.deleteAll();
193+
}
194+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
195+
LOGGER.error("Unable to clear accumulo namespace", ex);
196+
}
163197
Assert.fail("Error occurred while testing a polygon and time range query of spatial temporal index: '" + e.getLocalizedMessage() + "'");
164198
}
165199

@@ -171,10 +205,20 @@ public void testIngestAndQuerySpatialTemporalPointsAndLines() {
171205
}
172206
catch (final Exception e) {
173207
e.printStackTrace();
174-
accumuloOperations.deleteAll();
208+
try {
209+
accumuloOperations.deleteAll();
210+
}
211+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
212+
LOGGER.error("Unable to clear accumulo namespace", ex);
213+
}
175214
Assert.fail("Error occurred while testing deletion of an entry using spatial temporal index: '" + e.getLocalizedMessage() + "'");
176215
}
177-
accumuloOperations.deleteAll();
216+
try {
217+
accumuloOperations.deleteAll();
218+
}
219+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
220+
LOGGER.error("Unable to clear accumulo namespace", ex);
221+
}
178222
}
179223

180224
private void testIngest(
@@ -242,12 +286,23 @@ private void testQuery(
242286
totalResults++;
243287
}
244288
else {
245-
accumuloOperations.deleteAll();
289+
try {
290+
accumuloOperations.deleteAll();
291+
}
292+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
293+
LOGGER.error("Unable to clear accumulo namespace", ex);
294+
}
246295
Assert.fail("Actual result '" + obj.toString() + "' is not of type Simple Feature.");
247296
}
248297
}
249298
if (expectedResults.count != totalResults) {
250-
accumuloOperations.deleteAll();
299+
try {
300+
accumuloOperations.deleteAll();
301+
}
302+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
303+
LOGGER.error("Unable to clear accumulo namespace", ex);
304+
Assert.fail("Unable to clear accumulo namespace");
305+
}
251306
}
252307
Assert.assertEquals(
253308
expectedResults.count,

geowave-test/src/test/java/mil/nga/giat/geowave/test/mapreduce/BasicMapReduceIT.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import mil.nga.giat.geowave.test.GeoWaveTestEnvironment;
3333
import mil.nga.giat.geowave.types.gpx.GpxIngestPlugin;
3434

35+
import org.apache.accumulo.core.client.AccumuloException;
36+
import org.apache.accumulo.core.client.AccumuloSecurityException;
37+
import org.apache.accumulo.core.client.TableNotFoundException;
3538
import org.apache.commons.io.FilenameUtils;
3639
import org.apache.hadoop.conf.Configuration;
3740
import org.apache.hadoop.io.NullWritable;
@@ -66,7 +69,13 @@ public static enum ResultCounterType {
6669
@Test
6770
public void testIngestAndQueryGeneralGpx()
6871
throws Exception {
69-
accumuloOperations.deleteAll();
72+
try {
73+
accumuloOperations.deleteAll();
74+
}
75+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
76+
LOGGER.error("Unable to clear accumulo namespace", ex);
77+
Assert.fail("Index not deleted successfully");
78+
}
7079
testIngest(
7180
IndexType.SPATIAL_VECTOR,
7281
GENERAL_GPX_INPUT_GPX_DIR);
@@ -131,7 +140,13 @@ public boolean accept(
131140
@Test
132141
public void testIngestOsmGpxMultipleIndices()
133142
throws Exception {
134-
accumuloOperations.deleteAll();
143+
try {
144+
accumuloOperations.deleteAll();
145+
}
146+
catch (TableNotFoundException | AccumuloSecurityException | AccumuloException ex) {
147+
LOGGER.error("Unable to clear accumulo namespace", ex);
148+
Assert.fail("Index not deleted successfully");
149+
}
135150
// ingest the data set into multiple indices and then try several query
136151
// methods, by adapter and by index
137152
testIngest(

0 commit comments

Comments
 (0)