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

[#6076] improve(CLI): Support model pre event to Gravitino server #6250

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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;

/** Event representing the successful drop of a model. */
public class DeleteModelEvent extends ModelEvent {
private final boolean isExists;

/**
* Constructs an instance of {@code DeleteModelEvent}, capturing essential details about the
* successful drop of a model.
*
* @param user The username of the individual who initiated the model drop operation.
* @param identifier The unique identifier of the model that was dropped.
* @param isExists A boolean flag indicating whether the model existed at the time of the drop
* operation.
*/
public DeleteModelEvent(String user, NameIdentifier identifier, boolean isExists) {
super(user, identifier);
this.isExists = isExists;
}

/**
* Retrieves the existence status of the model at the time of the drop operation.
*
* @return A boolean value indicating whether the model existed. {@code true} if the model
* existed, otherwise {@code false}.
*/
public boolean isExists() {
return isExists;
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.DELETE_MODEL;
}

/**
* The status of the operation.
*
* @return The operation status.
*/
@Override
public OperationStatus operationStatus() {
return isExists() ? OperationStatus.SUCCESS : OperationStatus.UNPROCESSED;
}
}
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.gravitino.annotation.DeveloperApi;

/** Represents an event triggered before deleting a model. */
@DeveloperApi
public class DeleteModelPreEvent extends ModelPreEvent {

/**
* Create a new {@link DeleteModelPreEvent} instance.
*
* @param user the user who triggered the event.
* @param identifier the identifier of the model being operated on.
*/
public DeleteModelPreEvent(String user, NameIdentifier identifier) {
super(user, identifier);
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.DELETE_MODEL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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;

/**
* Represents an event that is generated after a model version is successfully dropped from the
* model.
*/
public class DeleteModelVersionEvent extends ModelEvent {

private final boolean isExists;

/**
* Constructs a new {@code DeleteModelVersionEvent} instance, encapsulating information about the
* outcome of a model version drop operation.
*
* @param user The user who initiated the drop model version operation.
* @param identifier The identifier of the model that was attempted to be dropped a version.
* @param isExists A boolean flag indicating whether the model version existed at the time of the
* drop operation.
*/
public DeleteModelVersionEvent(String user, NameIdentifier identifier, boolean isExists) {
super(user, identifier);
this.isExists = isExists;
}

/**
* Retrieves the existence status of the model version at the time of the drop operation.
*
* @return A boolean value indicating whether the model version existed. {@code true} if the model
* version existed, otherwise {@code false}.
*/
public boolean isExists() {
return isExists;
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.DELETE_MODEL_VERSION;
}

@Override
public OperationStatus operationStatus() {
return isExists() ? OperationStatus.SUCCESS : OperationStatus.UNPROCESSED;
}
}
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.gravitino.annotation.DeveloperApi;

/** Represents an event triggered before deleting a model version. */
@DeveloperApi
public class DeleteModelVersionPreEvent extends ModelPreEvent {

/**
* Create a new {@link DeleteModelVersionPreEvent} instance.
*
* @param user The username of the individual who initiated the model version linking.
* @param identifier The unique identifier of the model that was linked.
*/
public DeleteModelVersionPreEvent(String user, NameIdentifier identifier) {
super(user, identifier);
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.DELETE_MODEL_VERSION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.listener.api.info.ModelInfo;

/** Represents an event triggered upon the successful getting of a model. */
public class GetModelEvent extends ModelEvent {
private final ModelInfo modelInfo;

/**
* Constructs an instance of {@code GetModelEvent}, capturing essential details about the
* successful getting of a model.
*
* @param user The username of the individual who initiated the model get.
* @param identifier The unique identifier of the model that was get.
* @param modelInfo The state of the model post-get.
*/
public GetModelEvent(String user, NameIdentifier identifier, ModelInfo modelInfo) {
super(user, identifier);
this.modelInfo = modelInfo;
}

/**
* Retrieves the state of the model as it was made available to the user after successful getting.
*
* @return A {@link ModelInfo} instance encapsulating the details of the model as get.
*/
public ModelInfo getModelInfo() {
return modelInfo;
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.GET_MODEL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 triggered before getting a model. */
@DeveloperApi
public class GetModelPreEvent extends ModelPreEvent {
/**
* Create a new {@link GetModelPreEvent} instance.
*
* @param user the user who triggered the event.
* @param identifier the identifier of the model being operated on.
*/
public GetModelPreEvent(String user, NameIdentifier identifier) {
super(user, identifier);
}

/**
* Returns the type of operation.
*
* @return the operation type.
*/
@Override
public OperationType operationType() {
return OperationType.GET_MODEL;
}
}
Loading
Loading