forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* imply-5135 Complete tests * Extended result of getTables based on team feedback * Refactored getRunning maps according to PR comments * Made tables API more consistent * Fix broken unit tests * Added Derby test * PR feedback
- Loading branch information
Agustin Gonzalez
authored
Dec 10, 2020
1 parent
d283d90
commit 303c1e6
Showing
7 changed files
with
751 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
extensions-imply/ingest-service/src/main/java/io/imply/druid/ingest/metadata/Table.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) Imply Data, Inc. All rights reserved. | ||
* | ||
* This software is the confidential and proprietary information | ||
* of Imply Data, Inc. You shall not disclose such Confidential | ||
* Information and shall use it only in accordance with the terms | ||
* of the license agreement you entered into with Imply. | ||
*/ | ||
|
||
package io.imply.druid.ingest.metadata; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.apache.druid.server.security.Action; | ||
import org.joda.time.DateTime; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class Table | ||
{ | ||
private String name; | ||
private DateTime createdTime; | ||
private Set<Action> permissions = new HashSet<>(); | ||
|
||
public Table(Table table) | ||
{ | ||
this.name = table.getName(); | ||
this.createdTime = table.getCreatedTime(); | ||
this.permissions = new HashSet<>(table.getPermissions()); | ||
} | ||
|
||
@JsonCreator | ||
public Table( | ||
@JsonProperty("name") String name, | ||
@JsonProperty("createdTime") DateTime createdTime | ||
) | ||
{ | ||
this.name = name; | ||
this.createdTime = createdTime; | ||
} | ||
|
||
@JsonProperty | ||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
@JsonProperty | ||
public DateTime getCreatedTime() | ||
{ | ||
return createdTime; | ||
} | ||
|
||
|
||
@JsonProperty | ||
public Set<Action> getPermissions() | ||
{ | ||
return permissions; | ||
} | ||
|
||
public Table addPermissions(Action permission) | ||
{ | ||
this.permissions.add(permission); | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (o == this) { | ||
return true; | ||
} | ||
if (!(o instanceof Table)) { | ||
return false; | ||
} | ||
Table other = (Table) o; | ||
return this.name.equals(other.getName()) | ||
&& (this.getCreatedTime().equals(other.getCreatedTime())) | ||
&& (this.getPermissions().equals(other.getPermissions())); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return 31 * this.getName().hashCode() + | ||
this.getCreatedTime().hashCode() + | ||
this.getPermissions().hashCode() + | ||
super.hashCode(); | ||
} | ||
|
||
} |
102 changes: 102 additions & 0 deletions
102
...imply/ingest-service/src/main/java/io/imply/druid/ingest/metadata/TableJobStateStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) Imply Data, Inc. All rights reserved. | ||
* | ||
* This software is the confidential and proprietary information | ||
* of Imply Data, Inc. You shall not disclose such Confidential | ||
* Information and shall use it only in accordance with the terms | ||
* of the license agreement you entered into with Imply. | ||
*/ | ||
|
||
package io.imply.druid.ingest.metadata; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.imply.druid.ingest.jobs.JobState; | ||
import org.joda.time.DateTime; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class TableJobStateStats extends Table | ||
{ | ||
private List<JobStateCount> jobStateCounts = new ArrayList<>(); | ||
|
||
public TableJobStateStats(Table table) | ||
{ | ||
super(table); | ||
} | ||
|
||
@JsonCreator | ||
public TableJobStateStats( | ||
@JsonProperty("name") String name, | ||
@JsonProperty("createdTime") DateTime createdTime, | ||
@JsonProperty("jobState") JobState jobState, | ||
@JsonProperty("count") int count | ||
) | ||
{ | ||
super(name, createdTime); | ||
this.addJobState(jobState, count); | ||
} | ||
|
||
public TableJobStateStats addJobState(@Nullable JobState js, int count) | ||
{ | ||
if (js != null) { | ||
jobStateCounts.add(new JobStateCount(js, count)); | ||
} | ||
return this; | ||
} | ||
|
||
@JsonProperty | ||
public List<JobStateCount> getJobStateCounts() | ||
{ | ||
return jobStateCounts; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
// this extends Table which has implemented equals... | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
TableJobStateStats other = (TableJobStateStats) o; | ||
return (this.jobStateCounts.equals(other.getJobStateCounts())); | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return 31 * this.getPermissions().hashCode() + | ||
this.jobStateCounts.hashCode() + | ||
super.hashCode(); | ||
} | ||
|
||
public static class JobStateCount | ||
{ | ||
private JobState jobState; | ||
private int count; | ||
|
||
@JsonCreator | ||
public JobStateCount( | ||
@JsonProperty JobState js, | ||
@JsonProperty int count | ||
) | ||
{ | ||
this.jobState = js; | ||
this.count = count; | ||
} | ||
|
||
@JsonProperty | ||
public JobState getJobState() | ||
{ | ||
return jobState; | ||
} | ||
|
||
@JsonProperty | ||
public int getCount() | ||
{ | ||
return count; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.