-
Notifications
You must be signed in to change notification settings - Fork 392
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
4 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...-rest-server/src/main/java/org/apache/gravitino/iceberg/extension/IcebergEventLogger.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,62 @@ | ||
/* | ||
* 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.extension; | ||
|
||
import java.util.Map; | ||
import org.apache.gravitino.listener.api.EventListenerPlugin; | ||
import org.apache.gravitino.listener.api.event.Event; | ||
import org.apache.gravitino.listener.api.event.IcebergCreateTableEvent; | ||
import org.apache.gravitino.listener.api.event.IcebergUpdateTableEvent; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class IcebergEventLogger implements EventListenerPlugin { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(IcebergEventLogger.class); | ||
|
||
@Override | ||
public void init(Map<String, String> properties) throws RuntimeException {} | ||
|
||
@Override | ||
public void start() throws RuntimeException {} | ||
|
||
@Override | ||
public void stop() throws RuntimeException {} | ||
|
||
@Override | ||
public void onPostEvent(Event event) throws RuntimeException { | ||
if (event instanceof IcebergCreateTableEvent) { | ||
LOG.info( | ||
"Create table event, request: {}", | ||
((IcebergCreateTableEvent) event).createTableRequest()); | ||
} else if (event instanceof IcebergUpdateTableEvent) { | ||
LOG.info( | ||
"Update table event, request: {}", | ||
((IcebergUpdateTableEvent) event).updateTableRequest()); | ||
} else { | ||
LOG.info("Unknown event: {}", event.getClass().getSimpleName()); | ||
} | ||
} | ||
|
||
@Override | ||
public Mode mode() { | ||
return Mode.ASYNC_ISOLATED; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateTableEvent.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,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.gravitino.listener.api.event; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.iceberg.rest.requests.CreateTableRequest; | ||
import org.apache.iceberg.rest.responses.LoadTableResponse; | ||
|
||
public class IcebergCreateTableEvent extends IcebergEvent { | ||
|
||
private CreateTableRequest createTableRequest; | ||
private LoadTableResponse loadTableResponse; | ||
|
||
public IcebergCreateTableEvent( | ||
String user, | ||
NameIdentifier resourceIdentifier, | ||
CreateTableRequest createTableRequest, | ||
LoadTableResponse loadTableResponse) { | ||
super(user, resourceIdentifier); | ||
this.createTableRequest = createTableRequest; | ||
this.loadTableResponse = loadTableResponse; | ||
} | ||
|
||
public CreateTableRequest createTableRequest() { | ||
return createTableRequest; | ||
} | ||
|
||
public LoadTableResponse loadTableResponse() { | ||
return loadTableResponse; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...eberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergEvent.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,28 @@ | ||
/* | ||
* 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.listener.api.event; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
|
||
public abstract class IcebergEvent extends Event { | ||
public IcebergEvent(String user, NameIdentifier resourceIdentifier) { | ||
super(user, resourceIdentifier); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateTableEvent.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,49 @@ | ||
/* | ||
* 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.listener.api.event; | ||
|
||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.iceberg.rest.requests.UpdateTableRequest; | ||
import org.apache.iceberg.rest.responses.LoadTableResponse; | ||
|
||
public class IcebergUpdateTableEvent extends IcebergEvent { | ||
|
||
private UpdateTableRequest updateTableRequest; | ||
// Iceberg table information after the table is updated. | ||
private LoadTableResponse loadTableResponse; | ||
|
||
public IcebergUpdateTableEvent( | ||
String user, | ||
NameIdentifier resourceIdentifier, | ||
UpdateTableRequest updateTableRequest, | ||
LoadTableResponse loadTableResponse) { | ||
super(user, resourceIdentifier); | ||
this.updateTableRequest = updateTableRequest; | ||
this.loadTableResponse = loadTableResponse; | ||
} | ||
|
||
public UpdateTableRequest updateTableRequest() { | ||
return updateTableRequest; | ||
} | ||
|
||
public LoadTableResponse loadTableResponse() { | ||
return loadTableResponse; | ||
} | ||
} |