-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Foundation for the Druid metadata catalog #12647
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5ae0134
Foundation for the Druid metadata catalog
paul-rogers cdc339b
Build fixes
paul-rogers 04ec414
Build fixes
paul-rogers 50c267b
And there was much renaming
paul-rogers d18a512
More renaming & build fixes
paul-rogers 27614b9
Fix warning
paul-rogers 79bba46
Build fix
paul-rogers 551b901
IT fix
paul-rogers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
48 changes: 48 additions & 0 deletions
48
core/src/test/java/org/apache/druid/metadata/MetadataStorageTablesConfigTest.java
This file contains hidden or 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,48 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.metadata; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| public class MetadataStorageTablesConfigTest | ||
| { | ||
| /** | ||
| * Pretty lame test: mostly to get the static checks to not complain. | ||
| */ | ||
| @Test | ||
| public void testDefaults() | ||
| { | ||
| MetadataStorageTablesConfig config = MetadataStorageTablesConfig.fromBase(null); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE, config.getBase()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_dataSource", config.getDataSourceTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_pendingSegments", config.getPendingSegmentsTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_segments", config.getSegmentsTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_rules", config.getRulesTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_config", config.getConfigTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_tasks", config.getTasksTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_tasklogs", config.getTaskLogTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_tasklocks", config.getTaskLockTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_audit", config.getAuditTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_supervisors", config.getSupervisorTable()); | ||
| assertEquals(MetadataStorageTablesConfig.DEFAULT_BASE + "_tableDefn", config.getTableDefnTable()); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
104 changes: 104 additions & 0 deletions
104
server/src/main/java/org/apache/druid/catalog/Actions.java
This file contains hidden or 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,104 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.catalog; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import org.apache.druid.server.security.ForbiddenException; | ||
|
|
||
| import javax.ws.rs.core.Response; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Helper functions for the catalog REST API actions. | ||
| */ | ||
| public class Actions | ||
| { | ||
| public static final String DUPLICATE_ERROR = "Already exists"; | ||
| public static final String FAILED_ERROR = "Failed"; | ||
| public static final String INVALID = "Invalid"; | ||
| public static final String FORBIDDEN = "Forbidden"; | ||
| public static final String NOT_FOUND = "Not found"; | ||
|
|
||
| public static final String ERROR_KEY = "error"; | ||
| public static final String ERR_MSG_KEY = "errorMessage"; | ||
|
|
||
| public static Map<String, String> error(String code, String msg) | ||
| { | ||
| return ImmutableMap.of(ERROR_KEY, code, ERR_MSG_KEY, msg); | ||
| } | ||
|
|
||
| public static Response exception(Exception e) | ||
| { | ||
| return Response | ||
| .serverError() | ||
| .entity(error(FAILED_ERROR, e.getMessage())) | ||
| .build(); | ||
| } | ||
|
|
||
| public static Response badRequest(String code, String msg) | ||
| { | ||
| return Response | ||
| .status(Response.Status.BAD_REQUEST) | ||
| .entity(error(code, msg)) | ||
| .build(); | ||
| } | ||
|
|
||
| public static Response notFound(String msg) | ||
| { | ||
| return Response | ||
| .status(Response.Status.NOT_FOUND) | ||
| .entity(error(NOT_FOUND, msg)) | ||
| .build(); | ||
| } | ||
|
|
||
| public static Response ok() | ||
| { | ||
| return Response.ok().build(); | ||
| } | ||
|
|
||
| public static Response forbidden() | ||
| { | ||
| return forbidden("Unauthorized"); | ||
| } | ||
|
|
||
| public static Response forbidden(ForbiddenException e) | ||
| { | ||
| return forbidden(e.getMessage()); | ||
| } | ||
|
|
||
| public static Response forbidden(String msg) | ||
| { | ||
| // Like ForbiddenExceptionMapper, but in the standard error | ||
| // format. Used instead of throwing ForbiddenException | ||
| return Response.status(Response.Status.FORBIDDEN) | ||
| .entity(error(FORBIDDEN, msg)) | ||
| .build(); | ||
| } | ||
|
|
||
| public static Response okWithVersion(long version) | ||
| { | ||
| return Response | ||
| .ok() | ||
| .entity(ImmutableMap.of("version", version)) | ||
| .build(); | ||
|
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are you thinking this class would be useful for other server APIs in the future? It seems written in such a way that it would be.
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.
Yes. I've already written variations of these several times here and there in Druid. Making it more general is left as a later exercise to minimize the size of this PR.