27
27
import org .apache .accumulo .core .conf .SiteConfiguration ;
28
28
import org .apache .accumulo .core .fate .zookeeper .ZooReaderWriter ;
29
29
import org .apache .accumulo .core .fate .zookeeper .ZooUtil .NodeMissingPolicy ;
30
- import org .apache .accumulo .core .lock .ServiceLock ;
31
30
import org .apache .accumulo .core .lock .ServiceLockPaths .AddressSelector ;
32
31
import org .apache .accumulo .core .lock .ServiceLockPaths .ResourceGroupPredicate ;
33
32
import org .apache .accumulo .core .lock .ServiceLockPaths .ServiceLockPath ;
@@ -103,7 +102,7 @@ public void zap(SiteConfiguration siteConf, String... args) {
103
102
Opts opts = new Opts ();
104
103
opts .parseArgs (keyword (), args );
105
104
106
- if (!opts .zapManager && !opts .zapTservers ) {
105
+ if (!opts .zapManager && !opts .zapTservers && ! opts . zapCompactors && ! opts . zapScanServers ) {
107
106
new JCommander (opts ).usage ();
108
107
return ;
109
108
}
@@ -136,21 +135,12 @@ public void zap(SiteConfiguration siteConf, String... args) {
136
135
try {
137
136
Set <ServiceLockPath > tserverLockPaths =
138
137
context .getServerPaths ().getTabletServer (rgp , AddressSelector .all (), false );
139
- for (ServiceLockPath tserverPath : tserverLockPaths ) {
140
-
141
- message ("Deleting " + tserverPath + " from zookeeper" , opts );
142
-
143
- if (opts .zapManager ) {
144
- zrw .recursiveDelete (tserverPath .toString (), NodeMissingPolicy .SKIP );
145
- } else {
146
- if (!zrw .getChildren (tserverPath .toString ()).isEmpty ()) {
147
- try {
148
- ServiceLock .deleteLock (zrw , tserverPath );
149
- } catch (RuntimeException e ) {
150
- message ("Did not delete " + tserverPath , opts );
151
- }
152
- }
153
- }
138
+ Set <String > tserverResourceGroupPaths = new HashSet <>();
139
+ tserverLockPaths .forEach (p -> tserverResourceGroupPaths
140
+ .add (p .toString ().substring (0 , p .toString ().lastIndexOf ('/' ))));
141
+ for (String group : tserverResourceGroupPaths ) {
142
+ message ("Deleting tserver " + group + " from zookeeper" , opts );
143
+ zrw .recursiveDelete (group .toString (), NodeMissingPolicy .SKIP );
154
144
}
155
145
} catch (KeeperException | InterruptedException e ) {
156
146
log .error ("{}" , e .getMessage (), e );
@@ -165,7 +155,7 @@ public void zap(SiteConfiguration siteConf, String... args) {
165
155
.add (p .toString ().substring (0 , p .toString ().lastIndexOf ('/' ))));
166
156
try {
167
157
for (String group : compactorResourceGroupPaths ) {
168
- message ("Deleting " + group + " from zookeeper" , opts );
158
+ message ("Deleting compactor " + group + " from zookeeper" , opts );
169
159
zrw .recursiveDelete (group , NodeMissingPolicy .SKIP );
170
160
}
171
161
} catch (KeeperException | InterruptedException e ) {
@@ -175,14 +165,16 @@ public void zap(SiteConfiguration siteConf, String... args) {
175
165
}
176
166
177
167
if (opts .zapScanServers ) {
168
+ Set <ServiceLockPath > sserverLockPaths =
169
+ context .getServerPaths ().getScanServer (rgp , AddressSelector .all (), false );
170
+ Set <String > sserverResourceGroupPaths = new HashSet <>();
171
+ sserverLockPaths .forEach (p -> sserverResourceGroupPaths
172
+ .add (p .toString ().substring (0 , p .toString ().lastIndexOf ('/' ))));
173
+
178
174
try {
179
- Set <ServiceLockPath > sserverLockPaths =
180
- context .getServerPaths ().getScanServer (rgp , AddressSelector .all (), false );
181
- for (ServiceLockPath sserverPath : sserverLockPaths ) {
182
- message ("Deleting " + sserverPath + " from zookeeper" , opts );
183
- if (!zrw .getChildren (sserverPath .toString ()).isEmpty ()) {
184
- ServiceLock .deleteLock (zrw , sserverPath );
185
- }
175
+ for (String group : sserverResourceGroupPaths ) {
176
+ message ("Deleting sserver " + group + " from zookeeper" , opts );
177
+ zrw .recursiveDelete (group , NodeMissingPolicy .SKIP );
186
178
}
187
179
} catch (KeeperException | InterruptedException e ) {
188
180
log .error ("{}" , e .getMessage (), e );
0 commit comments