-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
676 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ | |
|
||
tasks.all { | ||
enabled = false | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
...ain/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableEventDispatcher.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,77 @@ | ||
/* | ||
* 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.gravitino.iceberg.service.dispatcher; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.gravitino.iceberg.service.IcebergRestUtils; | ||
import org.apache.gravitino.listener.EventBus; | ||
import org.apache.gravitino.listener.api.event.IcebergCreateTableEvent; | ||
import org.apache.gravitino.listener.api.event.IcebergCreateTableFailureEvent; | ||
import org.apache.gravitino.listener.api.event.IcebergCreateTablePreEvent; | ||
import org.apache.gravitino.utils.PrincipalUtils; | ||
import org.apache.iceberg.catalog.Namespace; | ||
import org.apache.iceberg.catalog.TableIdentifier; | ||
import org.apache.iceberg.rest.requests.CreateTableRequest; | ||
import org.apache.iceberg.rest.responses.LoadTableResponse; | ||
|
||
/** | ||
* {@code IcebergTableEventDispatcher} is a decorator for {@link IcebergTableOperationExecutor} that | ||
* not only delegates table operations to the underlying dispatcher but also dispatches | ||
* corresponding events to an {@link org.apache.gravitino.listener.EventBus}. | ||
*/ | ||
public class IcebergTableEventDispatcher implements IcebergTableOperationDispatcher { | ||
|
||
private IcebergTableOperationDispatcher icebergTableOperationDispatcher; | ||
private EventBus eventBus; | ||
|
||
public IcebergTableEventDispatcher( | ||
IcebergTableOperationDispatcher icebergTableOperationDispatcher, EventBus eventBus) { | ||
this.icebergTableOperationDispatcher = icebergTableOperationDispatcher; | ||
this.eventBus = eventBus; | ||
} | ||
|
||
@Override | ||
public LoadTableResponse createTable( | ||
String catalogName, Namespace namespace, CreateTableRequest createTableRequest) { | ||
TableIdentifier tableIdentifier = TableIdentifier.of(namespace, createTableRequest.name()); | ||
NameIdentifier nameIdentifier = | ||
IcebergRestUtils.getGravitinoNameIdentifier(catalogName, tableIdentifier); | ||
eventBus.dispatchEvent( | ||
new IcebergCreateTablePreEvent( | ||
PrincipalUtils.getCurrentUserName(), nameIdentifier, createTableRequest)); | ||
LoadTableResponse loadTableResponse; | ||
try { | ||
loadTableResponse = | ||
icebergTableOperationDispatcher.createTable(catalogName, namespace, createTableRequest); | ||
} catch (Exception e) { | ||
eventBus.dispatchEvent( | ||
new IcebergCreateTableFailureEvent( | ||
PrincipalUtils.getCurrentUserName(), nameIdentifier, e)); | ||
throw e; | ||
} | ||
eventBus.dispatchEvent( | ||
new IcebergCreateTableEvent( | ||
PrincipalUtils.getCurrentUserName(), | ||
nameIdentifier, | ||
createTableRequest, | ||
loadTableResponse)); | ||
return loadTableResponse; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...java/org/apache/gravitino/iceberg/service/dispatcher/IcebergTableOperationDispatcher.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,41 @@ | ||
/* | ||
* 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.gravitino.iceberg.service.dispatcher; | ||
|
||
import org.apache.iceberg.catalog.Namespace; | ||
import org.apache.iceberg.rest.requests.CreateTableRequest; | ||
import org.apache.iceberg.rest.responses.LoadTableResponse; | ||
|
||
/** | ||
* The {@code IcebergTableOperationDispatcher} interface defines the public API for managing Iceberg | ||
* tables. | ||
*/ | ||
public interface IcebergTableOperationDispatcher { | ||
/** | ||
* Creates a new Iceberg table. | ||
* | ||
* @param catalogName The catalog name when creating the table. | ||
* @param namespace The namespace within which the table should be created. | ||
* @param createTableRequest The request object containing the details for creating the table. | ||
* @return A {@link LoadTableResponse} object containing the result of the operation. | ||
*/ | ||
LoadTableResponse createTable( | ||
String catalogName, Namespace namespace, CreateTableRequest createTableRequest); | ||
} |
Oops, something went wrong.