Search in sources :

Example 1 with CRLStatus

use of org.apache.hadoop.hdds.security.x509.crl.CRLStatus in project ozone by apache.

the class CRLStatusReportHandler method onMessage.

@Override
public void onMessage(CRLStatusReportFromDatanode reportFromDatanode, EventPublisher publisher) {
    if (isSecurityEnabled) {
        Preconditions.checkNotNull(reportFromDatanode);
        DatanodeDetails dn = reportFromDatanode.getDatanodeDetails();
        Preconditions.checkNotNull(dn, "CRLStatusReport is " + "missing DatanodeDetails.");
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Processing CRL status report for dn: {}", dn);
        }
        CRLStatusReport crlStatusReport = reportFromDatanode.getReport();
        long receivedCRLId = crlStatusReport.getReceivedCrlId();
        List<Long> pendingCRLIds = crlStatusReport.getPendingCrlIdsList();
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Updating Processed CRL Id: {} and Pending CRL Ids: {} ", receivedCRLId, pendingCRLIds);
        }
        CRLStatus crlStatus = new CRLStatus(receivedCRLId, pendingCRLIds);
        certStore.setCRLStatusForDN(dn.getUuid(), crlStatus);
    // Todo: send command for new CRL
    // if crl > dn received crl id, then send a command to DN to process the
    // new CRL via heartbeat response.
    }
}
Also used : DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) CRLStatusReport(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CRLStatusReport) CRLStatus(org.apache.hadoop.hdds.security.x509.crl.CRLStatus)

Example 2 with CRLStatus

use of org.apache.hadoop.hdds.security.x509.crl.CRLStatus in project ozone by apache.

the class TestCRLStatusReportHandler method testCRLStatusReport.

@Test
public void testCRLStatusReport() {
    DatanodeDetails dn1 = MockDatanodeDetails.randomDatanodeDetails();
    DatanodeDetails dn2 = MockDatanodeDetails.randomDatanodeDetails();
    List<Long> pendingCRLIds1 = new ArrayList<>();
    List<Long> pendingCRLIds2 = new ArrayList<>();
    pendingCRLIds1.add(3L);
    pendingCRLIds1.add(4L);
    pendingCRLIds2.add(1L);
    CRLStatusReportFromDatanode reportFromDatanode1 = getCRLStatusReport(dn1, pendingCRLIds1, 5L);
    CRLStatusReportFromDatanode reportFromDatanode2 = getCRLStatusReport(dn2, pendingCRLIds2, 2L);
    crlStatusReportHandler.onMessage(reportFromDatanode1, this);
    CRLStatus crlStatus = certificateStore.getCRLStatusForDN(dn1.getUuid());
    Assert.assertTrue(crlStatus.getPendingCRLIds().containsAll(pendingCRLIds1));
    Assert.assertEquals(5L, crlStatus.getReceivedCRLId());
    pendingCRLIds1.remove(0);
    reportFromDatanode1 = getCRLStatusReport(dn1, pendingCRLIds1, 6L);
    crlStatusReportHandler.onMessage(reportFromDatanode1, this);
    crlStatus = certificateStore.getCRLStatusForDN(dn1.getUuid());
    Assert.assertEquals(1, crlStatus.getPendingCRLIds().size());
    Assert.assertEquals(4L, crlStatus.getPendingCRLIds().get(0).longValue());
    Assert.assertEquals(6L, crlStatus.getReceivedCRLId());
    crlStatusReportHandler.onMessage(reportFromDatanode2, this);
    crlStatus = certificateStore.getCRLStatusForDN(dn2.getUuid());
    Assert.assertTrue(crlStatus.getPendingCRLIds().containsAll(pendingCRLIds2));
    Assert.assertEquals(2L, crlStatus.getReceivedCRLId());
}
Also used : MockDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) ArrayList(java.util.ArrayList) CRLStatus(org.apache.hadoop.hdds.security.x509.crl.CRLStatus) CRLStatusReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CRLStatusReportFromDatanode) Test(org.junit.Test)

Aggregations

DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 CRLStatus (org.apache.hadoop.hdds.security.x509.crl.CRLStatus)2 ArrayList (java.util.ArrayList)1 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)1 CRLStatusReport (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CRLStatusReport)1 CRLStatusReportFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CRLStatusReportFromDatanode)1 Test (org.junit.Test)1