use of org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl in project ozone by apache.
the class DecommissionOMSubcommand method call.
@Override
public Void call() throws IOException {
ozoneConf = parent.getParent().getOzoneConf();
user = parent.getParent().getUser();
verifyNodeIdAndHostAddress();
if (!force) {
verifyConfigUpdatedOnAllOMs();
}
// leader.
try (OMAdminProtocolClientSideImpl omAdminProtocolClient = OMAdminProtocolClientSideImpl.createProxyForOMHA(ozoneConf, user, omServiceId)) {
OMNodeDetails decommNodeDetails = new OMNodeDetails.Builder().setOMNodeId(decommNodeId).setHostAddress(hostInetAddress.getHostAddress()).build();
omAdminProtocolClient.decommission(decommNodeDetails);
System.out.println("Successfully decommissioned OM " + decommNodeId);
} catch (IOException e) {
System.out.println("Failed to decommission OM " + decommNodeId);
throw e;
}
return null;
}
use of org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl in project ozone by apache.
the class DecommissionOMSubcommand method checkOMConfig.
/**
* Check whether the to be decommissioned node is added to the
* OZONE_OM_DECOMMISSIONED_NODES_KEY.<SERVICE_ID> config in ozone-site.xml
* of given OM.
*/
private boolean checkOMConfig(OMNodeDetails omNodeDetails) throws IOException {
try (OMAdminProtocolClientSideImpl omAdminProtocolClient = OMAdminProtocolClientSideImpl.createProxyForSingleOM(ozoneConf, user, omNodeDetails)) {
OMConfiguration omConfig = omAdminProtocolClient.getOMConfiguration();
OMNodeDetails decommNodeDetails = omConfig.getDecommissionedNodesInNewConf().get(decommNodeId);
if (decommNodeDetails == null) {
return false;
}
if (!decommNodeDetails.getRpcAddress().getAddress().equals(hostInetAddress)) {
return false;
}
}
return true;
}
use of org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl in project ozone by apache.
the class TestAddRemoveOzoneManager method decommissionOM.
/**
* Decommission given OM and verify that the other OM's peer nodes are
* updated after decommissioning.
*/
private void decommissionOM(String decommNodeId) throws Exception {
Collection<String> decommNodes = conf.getTrimmedStringCollection(DECOMM_NODES_CONFIG_KEY);
decommNodes.add(decommNodeId);
conf.set(DECOMM_NODES_CONFIG_KEY, StringUtils.join(",", decommNodes));
List<OzoneManager> activeOMs = new ArrayList<>();
for (OzoneManager om : cluster.getOzoneManagersList()) {
String omNodeId = om.getOMNodeId();
if (cluster.isOMActive(omNodeId)) {
om.setConfiguration(conf);
activeOMs.add(om);
}
}
// Create OMAdmin protocol client to send decommission request
OMAdminProtocolClientSideImpl omAdminProtocolClient = OMAdminProtocolClientSideImpl.createProxyForOMHA(conf, user, OM_SERVICE_ID);
OMNodeDetails decommNodeDetails = new OMNodeDetails.Builder().setOMNodeId(decommNodeId).setHostAddress("localhost").build();
omAdminProtocolClient.decommission(decommNodeDetails);
// Verify decomm node is removed from the HA ring
GenericTestUtils.waitFor(() -> {
for (OzoneManager om : activeOMs) {
if (om.getPeerNodes().contains(decommNodeId)) {
return false;
}
}
return true;
}, 100, 100000);
// Wait for new leader election if required
GenericTestUtils.waitFor(() -> cluster.getOMLeader() != null, 500, 30000);
}
use of org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl in project ozone by apache.
the class OzoneManager method checkConfigBeforeBootstrap.
private void checkConfigBeforeBootstrap() throws IOException {
List<OMNodeDetails> omsWihtoutNewConfig = new ArrayList<>();
for (Map.Entry<String, OMNodeDetails> entry : peerNodesMap.entrySet()) {
String remoteNodeId = entry.getKey();
OMNodeDetails remoteNodeDetails = entry.getValue();
try (OMAdminProtocolClientSideImpl omAdminProtocolClient = OMAdminProtocolClientSideImpl.createProxyForSingleOM(configuration, getRemoteUser(), entry.getValue())) {
OMConfiguration remoteOMConfiguration = omAdminProtocolClient.getOMConfiguration();
checkRemoteOMConfig(remoteNodeId, remoteOMConfiguration);
} catch (IOException ioe) {
LOG.error("Remote OM config check failed on OM {}", remoteNodeId, ioe);
omsWihtoutNewConfig.add(remoteNodeDetails);
}
}
if (!omsWihtoutNewConfig.isEmpty()) {
String errorMsg = OmUtils.getOMAddressListPrintString(omsWihtoutNewConfig) + " do not have or have incorrect information of the bootstrapping " + "OM. Update their ozone-site.xml before proceeding.";
exitManager.exitSystem(1, errorMsg, LOG);
}
}
Aggregations