Skip to content
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

[hotfix] Add interface document and polish code #3268

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.streampark.console.core.service.application.ApplicationManageService;
import org.apache.streampark.console.core.watcher.FlinkAppHttpWatcher;
import org.apache.streampark.console.system.entity.AccessToken;
import org.apache.streampark.console.system.entity.Member;
import org.apache.streampark.console.system.entity.User;
import org.apache.streampark.console.system.service.MemberService;

Expand Down Expand Up @@ -126,17 +125,15 @@ public RestResponse permissionAction(ProceedingJoinPoint joinPoint) throws Throw
"Permission denied, only user himself can access this permission");
break;
case TEAM:
Member member = memberService.findByUserName(paramId, currentUser.getUsername());
ApiAlertException.throwIfTrue(
member == null,
memberService.findByUserName(paramId, currentUser.getUsername()) == null,
"Permission denied, only user belongs to this team can access this permission");
break;
case APP:
Application app = applicationManageService.getById(paramId);
ApiAlertException.throwIfTrue(app == null, "Invalid operation, application is null");
member = memberService.findByUserName(app.getTeamId(), currentUser.getUsername());
ApiAlertException.throwIfTrue(
member == null,
memberService.findByUserName(app.getTeamId(), currentUser.getUsername()) == null,
"Permission denied, only user belongs to this team can access this permission");
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,61 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;

/** Interface representing a service for application backup operations. */
public interface ApplicationBackUpService extends IService<ApplicationBackUp> {

/**
* Deletes an object specified by the given ID.
*
* @param id The ID of the object to delete.
* @return true if the object was successfully deleted, false otherwise.
* @throws InternalException if an internal error occurs during the deletion process.
*/
Boolean delete(Long id) throws InternalException;

/**
* Performs a backup for the given application and Flink SQL parameters.
*
* @param appParam The application to back up.
* @param flinkSqlParam The Flink SQL to back up.
*/
void backup(Application appParam, FlinkSql flinkSqlParam);

/**
* Retrieves a page of {@link ApplicationBackUp} objects based on the provided parameters.
*
* @param bakParam The {@link ApplicationBackUp} object containing the search criteria.
* @param request The {@link RestRequest} object used for pagination and sorting.
* @return An {@link IPage} containing the retrieved {@link ApplicationBackUp} objects.
*/
IPage<ApplicationBackUp> page(ApplicationBackUp bakParam, RestRequest request);

/**
* Rolls back the changes made by the specified application backup.
*
* @param bakParam The ApplicationBackUp object representing the backup to roll back.
*/
void rollback(ApplicationBackUp bakParam);

/**
* Revoke the given application.
*
* @param appParam The application to be revoked.
*/
void revoke(Application appParam);

/**
* Removes the specified application.
*
* @param appParam the application to be removed
*/
void removeApp(Application appParam);

/**
* Rolls back a Flink SQL application to its previous state.
*
* @param appParam The application to rollback.
* @param flinkSqlParam The Flink SQL instance associated with the application.
*/
void rollbackFlinkSql(Application appParam, FlinkSql flinkSqlParam);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,101 @@

import java.util.List;

/** This interface defines the methods to manage the application configuration. */
public interface ApplicationConfigService extends IService<ApplicationConfig> {

void create(Application application, Boolean latest);

void update(Application application, Boolean latest);

/**
* Creates a new instance of an Application.
*
* @param appParam The Application object to create.
* @param latest If set to true, sets the created Application as the latest version.
*/
void create(Application appParam, Boolean latest);

/**
* Updates the given application.
*
* @param appParam the application to be updated
* @param latest a boolean indicating whether to update to the latest version
*/
void update(Application appParam, Boolean latest);

/**
* Sets the latest or effective flag for a given configuration and application. The latest flag
* determines whether the configuration is the latest version available. The effective flag
* determines whether the configuration is effective for the application.
*
* @param latest a boolean value indicating whether the configuration is the latest version (true)
* or not (false)
* @param configId the ID of the configuration
* @param appId the ID of the application
*/
void setLatestOrEffective(Boolean latest, Long configId, Long appId);

/**
* Sets the configuration to effective for the given application and configuration ID.
*
* @param appId The ID of the application
* @param configId The ID of the configuration
*/
void toEffective(Long appId, Long configId);

/**
* Returns the latest version of the application configuration for the given application ID.
*
* @param appId The ID of the application
* @return The latest version of the application configuration
*/
ApplicationConfig getLatest(Long appId);

/**
* Retrieves the effective ApplicationConfig for the given appId.
*
* @param appId The identifier of the application.
* @return The effective ApplicationConfig.
*/
ApplicationConfig getEffective(Long appId);

/**
* Retrieves the ApplicationConfig for the specified ID.
*
* @param id the ID of the ApplicationConfig to retrieve
* @return the ApplicationConfig object corresponding to the specified ID, or null if no
* ApplicationConfig is found
*/
ApplicationConfig get(Long id);

/**
* Retrieves a page of ApplicationConfig objects based on the specified ApplicationConfig and
* RestRequest.
*
* @param config the ApplicationConfig object to use as a filter for retrieving the page
* @param request the RestRequest object containing additional parameters and settings for
* retrieving the page
* @return an IPage containing the ApplicationConfig objects that match the filter criteria
* specified in the config object, limited by the settings in the request object
*/
IPage<ApplicationConfig> page(ApplicationConfig config, RestRequest request);

List<ApplicationConfig> history(Application application);

/**
* Retrieves the history of application configurations for a given application.
*
* @param appParam The application for which to retrieve the history.
* @return The list of application configurations representing the history.
*/
List<ApplicationConfig> history(Application appParam);

/**
* Reads a template from a file or a database.
*
* @return the content of the template as a String
*/
String readTemplate();

/**
* Removes the app with the specified appId.
*
* @param appId The id of the app to be removed.
*/
void removeApp(Long appId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,84 @@
public interface FlinkEnvService extends IService<FlinkEnv> {

/**
* check exists
* Checks if a specific version of Flink exists.
*
* @param version
* @return
* @param version The version of Flink to check.
* @return Returns an Integer value indicating the existence of the specified version: - 0 if the
* version exists - 1 if the version does not exist - null if the version is invalid or an
* error occurred during the check
*/
Integer check(FlinkEnv version);

/**
* create new
* Create a new instance.
*
* @param version
* @throws IOException
* @param version The version of FlinkEnv to use.
* @throws Exception if an error occurs during the creation process.
* @return true if the instance is successfully created, false otherwise.
*/
boolean create(FlinkEnv version) throws Exception;

/**
* delete flink env
* Deletes a Flink environment with the provided ID.
*
* @param id
* @param id the ID of the Flink environment to delete
*/
void delete(Long id);

/**
* update
* Updates the specified version of Flink environment.
*
* @param version
* @throws IOException
* @param version the version of Flink environment to update
* @throws IOException if an I/O error occurs during the update process
*/
void update(FlinkEnv version) throws IOException;

/**
* get flink version by appid
* Get flink version by application id.
*
* @param appId
* @return
* @param appId the ID of the application
* @return the FlinkEnv object representing the version of Flink associated with the given app ID
*/
FlinkEnv getByAppId(Long appId);

/**
* set a flink version as the default
* Sets the specified Flink version as the default.
*
* @param id
* @param id The ID of the Flink version to set as the default.
*/
void setDefault(Long id);

/**
* get default version
* Retrieves the default version of FlinkEnv.
*
* @return
* @return the default version of FlinkEnv
*/
FlinkEnv getDefault();

/**
* get flink version, if null, get default version
* Retrieves a Flink environment by ID, if available. If the ID is null or not found, the method
* returns the default Flink environment.
*
* @return
* @param id The ID of the Flink environment to retrieve. If null, the default environment will be
* retrieved.
* @return The Flink environment with the specified ID, or the default environment if the ID is
* null or not found.
*/
FlinkEnv getByIdOrDefault(Long id);

/**
* sycn conf file
* Synchronizes the configuration file for the given id.
*
* @param id
* @param id The id of the configuration file to be synchronized.
* @throws IOException If an I/O error occurs while synchronizing the configuration file.
*/
void syncConf(Long id) throws IOException;

/**
* Checks the validity of the given ID.
*
* @param id The ID to check for validity.
*/
void validity(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,63 @@

public interface SavePointService extends IService<SavePoint> {

/**
* Expires all savepoints for the specified application.
*
* @param appId the ID of the application to expire
*/
void expire(Long appId);

/**
* Retrieves the latest savepoint based on the given id.
*
* @param id the unique identifier of the SavePoint
* @return the latest SavePoint object, or null if not found
*/
SavePoint getLatest(Long id);

/**
* Triggers a savepoint for the specified application.
*
* @param appId the ID of the application to trigger the savepoint for
* @param savepointPath the path where the savepoint will be stored, or null if the default path
* should be used
* @param nativeFormat true to store the savepoint in native format, false otherwise
*/
void trigger(Long appId, @Nullable String savepointPath, @Nullable Boolean nativeFormat);

Boolean delete(Long id, Application application) throws InternalException;
/**
* Deletes an application with the specified ID.
*
* @param id the ID of the application to be deleted
* @param appParam the application object representing the application to be deleted
* @return true if the application is successfully deleted, false otherwise
* @throws InternalException if there is an internal error during the deletion process
*/
Boolean delete(Long id, Application appParam) throws InternalException;

/**
* Retrieves a page of savepoint objects based on the specified parameters.
*
* @param savePoint The SavePoint object to be used for filtering the page results.
* @param request The RestRequest object containing additional request parameters.
* @return An instance of IPage<SavePoint> representing the page of SavePoint objects.
*/
IPage<SavePoint> page(SavePoint savePoint, RestRequest request);

void removeApp(Application application);
/**
* Removes all savepoints for the specified application.
*
* @param appParam the application to be removed
*/
void removeApp(Application appParam);

String getSavePointPath(Application app) throws Exception;
/**
* Returns the savepoint path for the given application.
*
* @param appParam the application for which to get the save point path
* @return the save point path for the given application
* @throws Exception if an error occurs while getting the save point path
*/
String getSavePointPath(Application appParam) throws Exception;
}
Loading