49
49
import org .apache .accumulo .core .client .TableNotFoundException ;
50
50
import org .apache .accumulo .core .client .admin .ImportConfiguration ;
51
51
import org .apache .accumulo .core .client .admin .NewTableConfiguration ;
52
- import org .apache .accumulo .core .client .admin .TabletHostingGoal ;
52
+ import org .apache .accumulo .core .client .admin .TabletAvailability ;
53
53
import org .apache .accumulo .core .data .Key ;
54
54
import org .apache .accumulo .core .data .Mutation ;
55
55
import org .apache .accumulo .core .data .Range ;
@@ -96,18 +96,19 @@ protected Duration defaultTimeout() {
96
96
}
97
97
98
98
/**
99
- * Test that we can override a hosting goal when importing a table.
99
+ * Test that we can override a tablet availability when importing a table.
100
100
*/
101
101
@ Test
102
- public void importChangeHostingGoal () throws Exception {
102
+ public void overrideAvailabilityOnImport () throws Exception {
103
103
try (AccumuloClient client = Accumulo .newClient ().from (getClientProps ()).build ()) {
104
104
105
105
String [] tableNames = getUniqueNames (2 );
106
106
String srcTable = tableNames [0 ], destTable = tableNames [1 ];
107
107
108
- // create the source table with the initial hosting goal
109
- TabletHostingGoal srcGoal = TabletHostingGoal .ALWAYS ;
110
- NewTableConfiguration ntc = new NewTableConfiguration ().withInitialHostingGoal (srcGoal );
108
+ // create the source table with the initial tablet availability
109
+ TabletAvailability srcAvailability = TabletAvailability .HOSTED ;
110
+ NewTableConfiguration ntc =
111
+ new NewTableConfiguration ().withInitialTabletAvailability (srcAvailability );
111
112
client .tableOperations ().create (srcTable , ntc );
112
113
113
114
populateTable (client , srcTable );
@@ -121,8 +122,8 @@ public void importChangeHostingGoal() throws Exception {
121
122
log .info ("Exporting table to {}" , exportDir );
122
123
log .info ("Importing table from {}" , Arrays .toString (importDirs ));
123
124
124
- // ensure the table is the hosting goal we expect
125
- waitForHostingGoal (client , srcTable , srcGoal );
125
+ // ensure the table has the tablet availability we expect
126
+ waitForAvailability (client , srcTable , srcAvailability );
126
127
127
128
// Offline the table
128
129
client .tableOperations ().offline (srcTable , true );
@@ -132,16 +133,16 @@ public void importChangeHostingGoal() throws Exception {
132
133
copyExportedFilesToImportDirs (fs , exportDir , importDirs );
133
134
134
135
// Import the exported data into a new table
135
- final TabletHostingGoal newHostingGoal = TabletHostingGoal . NEVER ;
136
- assertNotEquals (srcGoal , newHostingGoal ,
137
- "New hosting goal should be different from the old one in order to test override." );
136
+ final TabletAvailability newAvailability = TabletAvailability . UNHOSTED ;
137
+ assertNotEquals (srcAvailability , newAvailability ,
138
+ "New tablet availability should be different from the old one in order to test we can override." );
138
139
139
140
ImportConfiguration importConfig =
140
- ImportConfiguration .builder ().setInitialHostingGoal ( newHostingGoal ).build ();
141
+ ImportConfiguration .builder ().setInitialAvailability ( newAvailability ).build ();
141
142
client .tableOperations ().importTable (destTable ,
142
143
Arrays .stream (importDirs ).map (Path ::toString ).collect (Collectors .toSet ()), importConfig );
143
144
144
- waitForHostingGoal (client , destTable , newHostingGoal );
145
+ waitForAvailability (client , destTable , newAvailability );
145
146
}
146
147
}
147
148
@@ -451,17 +452,19 @@ private void copyExportedFilesToImportDirs(FileSystem fs, Path exportDir, Path[]
451
452
}
452
453
}
453
454
454
- private static void waitForHostingGoal (AccumuloClient client , String tableName ,
455
- TabletHostingGoal goal ) {
455
+ private static void waitForAvailability (AccumuloClient client , String tableName ,
456
+ TabletAvailability expectedAvailability ) {
456
457
Wait .waitFor (() -> client .tableOperations ().getTabletInformation (tableName , new Range ())
457
458
.allMatch (tabletInformation -> {
458
- TabletHostingGoal currentGoal = tabletInformation .getHostingGoal ();
459
- boolean goalReached = currentGoal == goal ;
459
+ TabletAvailability currentAvailability = tabletInformation .getTabletAvailability ();
460
+ boolean goalReached = currentAvailability == expectedAvailability ;
460
461
if (!goalReached ) {
461
- log .info ("Current hosting goal: " + currentGoal + ". Waiting for " + goal );
462
+ log .info ("Current tablet availability: " + currentAvailability + ". Waiting for "
463
+ + expectedAvailability );
462
464
}
463
465
return goalReached ;
464
- }), 30_000L , 1_000L , "Timed out waiting for hosting goal " + goal + " on " + tableName );
466
+ }), 30_000L , 1_000L ,
467
+ "Timed out waiting for tablet availability " + expectedAvailability + " on " + tableName );
465
468
}
466
469
467
470
}
0 commit comments