-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4888] improvement(core): Add the implementations for `getFileLocati…
…on` interface in core module (#4891) ### What changes were proposed in this pull request? Add the implementations for `getFileLocation` interface in Core module. ### Why are the changes needed? Fix: #4888 ### How was this patch tested? Add some UTs. --------- Co-authored-by: xiaojiebao <[email protected]>
- Loading branch information
Showing
9 changed files
with
308 additions
and
5 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
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
80 changes: 80 additions & 0 deletions
80
core/src/main/java/org/apache/gravitino/listener/api/event/GetFileLocationEvent.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,80 @@ | ||
/* | ||
* 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 java.util.Map; | ||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.gravitino.annotation.DeveloperApi; | ||
|
||
/** Represents an event that occurs when getting an actual file location. */ | ||
@DeveloperApi | ||
public final class GetFileLocationEvent extends FilesetEvent { | ||
private final String actualFileLocation; | ||
private final String subPath; | ||
private final Map<String, String> context; | ||
|
||
/** | ||
* Constructs a new {@code GetFileLocationEvent}, recording the attempt to get a file location. | ||
* | ||
* @param user The user who initiated the get file location. | ||
* @param identifier The identifier of the file location that was attempted to be got. | ||
* @param actualFileLocation The actual file location which want to get. | ||
* @param subPath The accessing sub path of the get file location operation. | ||
* @param context The audit context, this param can be null. | ||
*/ | ||
public GetFileLocationEvent( | ||
String user, | ||
NameIdentifier identifier, | ||
String actualFileLocation, | ||
String subPath, | ||
Map<String, String> context) { | ||
super(user, identifier); | ||
this.actualFileLocation = actualFileLocation; | ||
this.subPath = subPath; | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* Get the actual file location after processing of the get file location operation. | ||
* | ||
* @return The actual file location. | ||
*/ | ||
public String actualFileLocation() { | ||
return actualFileLocation; | ||
} | ||
|
||
/** | ||
* Get the accessing sub path of the get file location operation. | ||
* | ||
* @return The accessing sub path. | ||
*/ | ||
public String subPath() { | ||
return subPath; | ||
} | ||
|
||
/** | ||
* Get the audit context map of the get file location operation. | ||
* | ||
* @return The audit context map. | ||
*/ | ||
public Map<String, String> context() { | ||
return context; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
core/src/main/java/org/apache/gravitino/listener/api/event/GetFileLocationFailureEvent.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,57 @@ | ||
/* | ||
* 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.gravitino.annotation.DeveloperApi; | ||
|
||
/** | ||
* Represents an event that is generated when an attempt to get a file location from the system | ||
* fails. | ||
*/ | ||
@DeveloperApi | ||
public final class GetFileLocationFailureEvent extends FilesetFailureEvent { | ||
private final String subPath; | ||
|
||
/** | ||
* Constructs a new {@code GetFileLocationFailureEvent}. | ||
* | ||
* @param user The user who initiated the get a file location. | ||
* @param identifier The identifier of the file location that was attempted to be got. | ||
* @param subPath The sub path of the actual file location which want to get. | ||
* @param exception The exception that was thrown during the get a file location. This exception | ||
* is key to diagnosing the failure, providing insights into what went wrong during the | ||
* operation. | ||
*/ | ||
public GetFileLocationFailureEvent( | ||
String user, NameIdentifier identifier, String subPath, Exception exception) { | ||
super(user, identifier, exception); | ||
this.subPath = subPath; | ||
} | ||
|
||
/** | ||
* Get the audit context map of the get file location operation. | ||
* | ||
* @return The audit context map. | ||
*/ | ||
public String subPath() { | ||
return subPath; | ||
} | ||
} |
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
Oops, something went wrong.