New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add interface to auto clean mysql pendingSegments table #3831
Changes from all commits
d135fbd
18eacab
e94a9d3
acc247f
c74ed25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package io.druid.timeline; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.joda.time.Interval; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Created by haoxiang on 16/11/11. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we generally dont have author info |
||
*/ | ||
public class TaskDataSegment | ||
{ | ||
|
||
private final String type; | ||
private final String id; | ||
private final String groupId; | ||
private final String dataSource; | ||
private final Map<String, Object> ioConfig; | ||
private final Interval interval; | ||
|
||
@JsonCreator | ||
public TaskDataSegment( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure this class is needed? What is the class used for serde when writing to pending Segments table? |
||
@JsonProperty("type") String type, | ||
@JsonProperty("id") String id, | ||
@JsonProperty("groupId") String groupId, | ||
@JsonProperty("dataSource") String dataSource, | ||
@JsonProperty("ioConfig") Map<String, Object> ioConfig, | ||
@JsonProperty("interval") Interval interval | ||
) | ||
{ | ||
this.type = type; | ||
this.id = id; | ||
this.groupId = groupId; | ||
this.dataSource = dataSource; | ||
this.ioConfig = ioConfig; | ||
this.interval = interval; | ||
} | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a weird comment |
||
* Get dataSource | ||
* | ||
* @return the dataSource | ||
*/ | ||
|
||
@JsonProperty | ||
public String getType() | ||
{ | ||
return type; | ||
} | ||
|
||
@JsonProperty | ||
public String getId() | ||
{ | ||
return id; | ||
} | ||
|
||
@JsonProperty | ||
public String getGroupId() | ||
{ | ||
return groupId; | ||
} | ||
|
||
@JsonProperty | ||
public String getDataSource() | ||
{ | ||
return dataSource; | ||
} | ||
|
||
@JsonProperty | ||
public Map<String, Object> getIoConfig() | ||
{ | ||
return ioConfig; | ||
} | ||
|
||
@JsonProperty | ||
public Interval getInterval() | ||
{ | ||
return interval; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "TaskDataSegment{" + | ||
"type=" + type + | ||
", id=" + id + | ||
", groupId=" + groupId + | ||
", dataSource=" + dataSource + | ||
'}'; | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import io.druid.indexing.overlord.SegmentPublishResult; | ||
import io.druid.segment.realtime.appenderator.SegmentIdentifier; | ||
import io.druid.timeline.DataSegment; | ||
import io.druid.timeline.TaskDataSegment; | ||
import org.joda.time.Interval; | ||
|
||
import java.io.IOException; | ||
|
@@ -39,10 +40,12 @@ public class TestIndexerMetadataStorageCoordinator implements IndexerMetadataSto | |
final private Set<DataSegment> published = Sets.newConcurrentHashSet(); | ||
final private Set<DataSegment> nuked = Sets.newConcurrentHashSet(); | ||
final private List<DataSegment> unusedSegments; | ||
final private List<TaskDataSegment> taskDataSegments; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inactiveTaskSegments |
||
|
||
public TestIndexerMetadataStorageCoordinator() | ||
{ | ||
unusedSegments = Lists.newArrayList(); | ||
taskDataSegments = Lists.newArrayList(); | ||
} | ||
|
||
@Override | ||
|
@@ -120,6 +123,12 @@ public void deleteSegments(Set<DataSegment> segments) | |
nuked.addAll(segments); | ||
} | ||
|
||
@Override | ||
public List<TaskDataSegment> getNotActiveTask(final Interval interval){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InactiveTasks* |
||
|
||
return ImmutableList.copyOf(taskDataSegments); | ||
} | ||
|
||
@Override | ||
public void updateSegmentMetadata(Set<DataSegment> segments) throws IOException | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
import io.druid.segment.realtime.appenderator.SegmentIdentifier; | ||
import io.druid.timeline.DataSegment; | ||
import io.druid.timeline.TaskDataSegment; | ||
import org.joda.time.Interval; | ||
|
||
import java.io.IOException; | ||
|
@@ -141,4 +142,11 @@ SegmentPublishResult announceHistoricalSegments( | |
* @return DataSegments which include ONLY data within the requested interval and are not flagged as used. Data segments NOT returned here may include data in the interval | ||
*/ | ||
List<DataSegment> getUnusedSegmentsForInterval(String dataSource, Interval interval); | ||
|
||
/** | ||
* Get all task which active property is 0, is used to delete the useless segments in pendingSegment table. | ||
* @param interval Filter the tasks to ones that include tasks in this interval exclusively. Start is inclusive, end is exclusive | ||
* @return The TaskDataSegment list which used to match the pendingSegment table's payload | ||
*/ | ||
List<TaskDataSegment> getNotActiveTask(final Interval interval); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InactiveTasks |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haoxiang47 there are many whitespace changes, can we please revert them?
https://github.com/druid-io/druid/pull/3831/files?w=1 indicates there's only new code added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also: https://github.com/druid-io/druid/blob/master/druid_intellij_formatting.xml