Search in sources :

Example 1 with OMAdminProtocolClientSideImpl

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

Example 2 with OMAdminProtocolClientSideImpl

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;
}
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 3 with OMAdminProtocolClientSideImpl

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

Example 4 with OMAdminProtocolClientSideImpl

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);
    }
}
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) ArrayList(java.util.ArrayList) CertificateSignRequest.getEncodedString(org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

OMNodeDetails (org.apache.hadoop.ozone.om.helpers.OMNodeDetails)4 OMAdminProtocolClientSideImpl (org.apache.hadoop.ozone.om.protocolPB.OMAdminProtocolClientSideImpl)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 OMConfiguration (org.apache.hadoop.ozone.om.protocol.OMConfiguration)2 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CertificateSignRequest.getEncodedString (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString)1