Search in sources :

Example 26 with SegmentMetadata

use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.

the class HelixBrokerStarterTest method addOneSegment.

private void addOneSegment(String tableName) {
    final SegmentMetadata segmentMetadata = new SimpleSegmentMetadata(tableName);
    LOGGER.info("Trying to add IndexSegment : " + segmentMetadata.getName());
    _pinotResourceManager.addSegment(segmentMetadata, "http://localhost:something");
}
Also used : SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata)

Example 27 with SegmentMetadata

use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.

the class RetentionManagerTest method testRetentionWithDaysTimeUnit.

/**
   * Test with daysSinceEpoch time unit and make 10 segments with expired time value, 10 segments
   * with the day after tomorrow's time stamp.
   * @throws JSONException
   * @throws UnsupportedEncodingException
   * @throws IOException
   * @throws InterruptedException
   */
@Test
public void testRetentionWithDaysTimeUnit() throws JSONException, UnsupportedEncodingException, IOException, InterruptedException {
    _retentionManager = new RetentionManager(_pinotHelixResourceManager, 5);
    _retentionManager.start();
    long theDayAfterTomorrowSinceEpoch = System.currentTimeMillis() / 1000 / 60 / 60 / 24 + 2;
    for (int i = 0; i < 10; ++i) {
        SegmentMetadata segmentMetadata = getTimeSegmentMetadataImpl("15544", "15544", TimeUnit.DAYS.toString());
        registerSegmentMetadata(segmentMetadata);
        Thread.sleep(100);
    }
    for (int i = 0; i < 10; ++i) {
        SegmentMetadata segmentMetadata = getTimeSegmentMetadataImpl(theDayAfterTomorrowSinceEpoch + "", theDayAfterTomorrowSinceEpoch + "", TimeUnit.DAYS.toString());
        registerSegmentMetadata(segmentMetadata);
        Thread.sleep(100);
    }
    validate(20, _offlineTableName, 10, true);
    cleanupSegments(_offlineTableName);
}
Also used : RetentionManager(com.linkedin.pinot.controller.helix.core.retention.RetentionManager) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 28 with SegmentMetadata

use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.

the class SegmentAssignmentStrategyTest method addOneSegment.

private void addOneSegment(String tableName) {
    final SegmentMetadata segmentMetadata = new SimpleSegmentMetadata(tableName);
    LOGGER.info("Trying to add IndexSegment : " + segmentMetadata.getName());
    _pinotHelixResourceManager.addSegment(segmentMetadata, "downloadUrl");
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata) SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata)

Example 29 with SegmentMetadata

use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.

the class PinotResourceManagerTest method testDeletingTheSameSegmentInSegmentDeletionManager.

@Test
public void testDeletingTheSameSegmentInSegmentDeletionManager() throws Exception {
    final SegmentMetadata segmentMetadata = new SimpleSegmentMetadata(TABLE_NAME);
    final String segmentName = segmentMetadata.getName();
    File segmentFile = new File(LOCAL_DISK_DIR + "/" + TABLE_NAME + "/" + segmentName);
    for (int i = 0; i < 2; i++) {
        addOneSegment(TABLE_NAME);
        // Waiting for the external view to update
        Thread.sleep(2000);
        final ExternalView externalView = _helixAdmin.getResourceExternalView(HELIX_CLUSTER_NAME, TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(TABLE_NAME));
        List<String> segmentsList = new ArrayList<>(externalView.getPartitionSet().size());
        segmentsList.addAll(externalView.getPartitionSet());
        _pinotHelixResourceManager.deleteSegments(TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(TABLE_NAME), segmentsList);
    }
    assert (!segmentFile.exists());
}
Also used : SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) ExternalView(org.apache.helix.model.ExternalView) ArrayList(java.util.ArrayList) File(java.io.File) SimpleSegmentMetadata(com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 30 with SegmentMetadata

use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.

the class ValidationManagerTest method testTotalDocumentCountRealTime.

@Test
public void testTotalDocumentCountRealTime() throws Exception {
    // Create a bunch of dummy segments
    String testTableName = "TestTableTotalDocCountTest";
    final String group1 = testTableName + "_REALTIME_1466446700000_34";
    final String group2 = testTableName + "_REALTIME_1466446700000_17";
    String segmentName1 = new HLCSegmentName(group1, "0", "1").getSegmentName();
    String segmentName2 = new HLCSegmentName(group1, "0", "2").getSegmentName();
    String segmentName3 = new HLCSegmentName(group1, "0", "3").getSegmentName();
    String segmentName4 = new HLCSegmentName(group2, "0", "3").getSegmentName();
    DummyMetadata metadata1 = new DummyMetadata(testTableName, segmentName1, 10);
    DummyMetadata metadata2 = new DummyMetadata(testTableName, segmentName2, 20);
    DummyMetadata metadata3 = new DummyMetadata(testTableName, segmentName3, 30);
    // This should get ignored in the count as it belongs to a different group id
    DummyMetadata metadata4 = new DummyMetadata(testTableName, segmentName4, 20);
    // Add them to a list
    List<SegmentMetadata> segmentMetadataList = new ArrayList<SegmentMetadata>();
    segmentMetadataList.add(metadata1);
    segmentMetadataList.add(metadata2);
    segmentMetadataList.add(metadata3);
    segmentMetadataList.add(metadata4);
    Assert.assertEquals(ValidationManager.computeRealtimeTotalDocumentInSegments(segmentMetadataList, true), 60);
    // Now add some low level segment names
    String segmentName5 = new LLCSegmentName(testTableName, 1, 0, 1000).getSegmentName();
    String segmentName6 = new LLCSegmentName(testTableName, 2, 27, 10000).getSegmentName();
    DummyMetadata metadata5 = new DummyMetadata(testTableName, segmentName5, 10);
    DummyMetadata metadata6 = new DummyMetadata(testTableName, segmentName6, 5);
    segmentMetadataList.add(metadata5);
    segmentMetadataList.add(metadata6);
    // Only the LLC segments should get counted.
    Assert.assertEquals(ValidationManager.computeRealtimeTotalDocumentInSegments(segmentMetadataList, false), 15);
}
Also used : HLCSegmentName(com.linkedin.pinot.common.utils.HLCSegmentName) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) LLCSegmentName(com.linkedin.pinot.common.utils.LLCSegmentName) Test(org.testng.annotations.Test)

Aggregations

SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)33 Test (org.testng.annotations.Test)10 SegmentMetadataImpl (com.linkedin.pinot.core.segment.index.SegmentMetadataImpl)8 SimpleSegmentMetadata (com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata)7 File (java.io.File)6 AfterTest (org.testng.annotations.AfterTest)6 BeforeTest (org.testng.annotations.BeforeTest)6 RetentionManager (com.linkedin.pinot.controller.helix.core.retention.RetentionManager)5 ArrayList (java.util.ArrayList)5 OfflineSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata)4 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)4 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)3 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)3 HashMap (java.util.HashMap)3 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)2 HLCSegmentName (com.linkedin.pinot.common.utils.HLCSegmentName)2 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)2 TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)2 Interval (org.joda.time.Interval)2 Matchers.anyString (org.mockito.Matchers.anyString)2