use of org.apache.hadoop.ozone.om.helpers.OMNodeDetails in project ozone by apache.
the class DecommissionOMSubcommand method verifyConfigUpdatedOnAllOMs.
/**
* Verify that the to be decommissioned node is added to the
* OZONE_OM_DECOMMISSIONED_NODES_KEY.<SERVICE_ID> config in ozone-site.xml
* of all OMs.
*/
private void verifyConfigUpdatedOnAllOMs() throws IOException {
String decommNodesKey = ConfUtils.addKeySuffixes(OZONE_OM_DECOMMISSIONED_NODES_KEY, omServiceId);
Collection<String> decommNodes = ozoneConf.getTrimmedStringCollection(decommNodesKey);
if (!decommNodes.contains(decommNodeId)) {
throw new IOException("Please add the to be decommissioned OM " + decommNodeId + " to the " + decommNodesKey + " config in " + "ozone-site.xml of all nodes.");
}
// For each OM, we need to get the reloaded config and check that the
// decommissioned node is either removed from ozone.om.nodes config or
// added to ozone.om.decommissioned.nodes
List<OMNodeDetails> activeOMNodeDetails = OmUtils.getAllOMHAAddresses(ozoneConf, omServiceId, false);
if (activeOMNodeDetails.isEmpty()) {
throw new IOException("Cannot decommission OM " + decommNodeId + " as " + "it is the only node in the ring.");
}
List<String> staleOMConfigs = new ArrayList<>();
for (OMNodeDetails nodeDetails : activeOMNodeDetails) {
if (!checkOMConfig(nodeDetails)) {
staleOMConfigs.add(nodeDetails.getNodeId());
}
}
if (!staleOMConfigs.isEmpty()) {
throw new IOException("OM(s) " + Strings.join(staleOMConfigs, ',') + " have not been updated with decommissioned nodes list or their" + " address for the decommissioning node does not match");
}
}
use of org.apache.hadoop.ozone.om.helpers.OMNodeDetails 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.helpers.OMNodeDetails 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.helpers.OMNodeDetails 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.helpers.OMNodeDetails in project ozone by apache.
the class TestOzoneManagerRatisServer method verifyRaftGroupIdGenerationWithCustomOmServiceId.
@Test
public void verifyRaftGroupIdGenerationWithCustomOmServiceId() throws Exception {
String customOmServiceId = "omSIdCustom123";
OzoneConfiguration newConf = new OzoneConfiguration();
String newOmId = UUID.randomUUID().toString();
String path = GenericTestUtils.getTempPath(newOmId);
Path metaDirPath = Paths.get(path, "om-meta");
newConf.set(HddsConfigKeys.OZONE_METADATA_DIRS, metaDirPath.toString());
newConf.setTimeDuration(OMConfigKeys.OZONE_OM_RATIS_MINIMUM_TIMEOUT_KEY, RATIS_RPC_TIMEOUT, TimeUnit.MILLISECONDS);
int ratisPort = 9873;
InetSocketAddress rpcAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
OMNodeDetails nodeDetails = new OMNodeDetails.Builder().setRpcAddress(rpcAddress).setRatisPort(ratisPort).setOMNodeId(newOmId).setOMServiceId(customOmServiceId).build();
// Starts a single node Ratis server
omRatisServer.stop();
OzoneManagerRatisServer newOmRatisServer = OzoneManagerRatisServer.newOMRatisServer(newConf, ozoneManager, nodeDetails, Collections.emptyMap(), secConfig, certClient, false);
newOmRatisServer.start();
UUID uuid = UUID.nameUUIDFromBytes(customOmServiceId.getBytes(UTF_8));
RaftGroupId raftGroupId = newOmRatisServer.getRaftGroup().getGroupId();
Assert.assertEquals(uuid, raftGroupId.getUuid());
Assert.assertEquals(raftGroupId.toByteString().size(), 16);
newOmRatisServer.stop();
}
Aggregations