Search in sources :

Example 1 with OMNodeDetails

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");
    }
}
Also used : OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with OMNodeDetails

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;
}
Also used : OMAdminProtocolClientSideImpl(org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl) OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) IOException(java.io.IOException)

Example 3 with OMNodeDetails

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;
}
Also used : OMAdminProtocolClientSideImpl(org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl) OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) OMConfiguration(org.apache.hadoop.ozone.om.protocol.OMConfiguration)

Example 4 with OMNodeDetails

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);
}
Also used : OMAdminProtocolClientSideImpl(org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl) OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) ArrayList(java.util.ArrayList)

Example 5 with OMNodeDetails

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();
}
Also used : Path(java.nio.file.Path) OMNodeDetails(org.apache.hadoop.ozone.om.helpers.OMNodeDetails) InetSocketAddress(java.net.InetSocketAddress) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) RaftGroupId(org.apache.ratis.protocol.RaftGroupId) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

OMNodeDetails (org.apache.hadoop.ozone.om.helpers.OMNodeDetails)18 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 InetSocketAddress (java.net.InetSocketAddress)4 OMAdminProtocolClientSideImpl (org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl)4 UncheckedIOException (java.io.UncheckedIOException)3 Map (java.util.Map)2 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 OMConfiguration (org.apache.hadoop.ozone.om.protocol.OMConfiguration)2 RaftPeer (org.apache.ratis.protocol.RaftPeer)2 Test (org.junit.Test)2 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CertificateSignRequest.getEncodedString (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString)1 OzoneIllegalArgumentException (org.apache.hadoop.ozone.OzoneIllegalArgumentException)1 OMFailoverProxyProvider (org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider)1 ServiceInfo (org.apache.hadoop.ozone.om.helpers.ServiceInfo)1