Skip to content
Draft
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
@@ -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.amoro.maintainer;

import org.apache.amoro.shade.guava32.com.google.common.base.MoreObjects;

import java.util.HashMap;
import java.util.Map;

/** Base implementation of MaintainerInput following BaseOptimizingInput pattern. */
public abstract class BaseMaintainerInput implements MaintainerInput {

private static final long serialVersionUID = 1L;

private final Map<String, String> options = new HashMap<>();

@Override
public void option(String name, String value) {
options.put(name, value);
}

@Override
public void options(Map<String, String> options) {
this.options.putAll(options);
}

@Override
public Map<String, String> getOptions() {
return options;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("operationType", getOperationType())
.add("tableIdentifier", getTableIdentifier())
.add("tableFormat", getTableFormat())
.add("options", options)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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.amoro.maintainer;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/** Base implementation of MaintainerOutput. */
public class BaseMaintainerOutput implements MaintainerOutput {

private static final long serialVersionUID = 1L;

private final Map<String, String> summary;
private final boolean success;
private final String errorMessage;

/** Create a successful maintainer output. */
public BaseMaintainerOutput() {
this(true, null);
}

/**
* Create a maintainer output with specified status.
*
* @param success whether the operation succeeded
* @param errorMessage error message if failed, null otherwise
*/
public BaseMaintainerOutput(boolean success, String errorMessage) {
this.summary = new HashMap<>();
this.success = success;
this.errorMessage = errorMessage;
}

@Override
public Map<String, String> summary() {
return Collections.unmodifiableMap(summary);
}

/**
* Add a summary entry.
*
* @param key summary key
* @param value summary value
*/
public void putSummary(String key, String value) {
summary.put(key, value);
}

@Override
public boolean isSuccess() {
return success;
}

@Override
public String getErrorMessage() {
return errorMessage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.amoro.maintainer;

import java.io.Serializable;

/**
* Executor interface for maintainer operations. Follows the same pattern as OptimizingExecutor.
*
* @param <I> the maintainer input type
* @param <O> the maintainer output type
*/
public interface MaintainerExecutor<I extends MaintainerInput, O extends MaintainerOutput>
extends Serializable {

/**
* Execute the maintainer operation.
*
* @return the maintainer output with execution results
*/
O execute();
}
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.amoro.maintainer;

import java.io.Serializable;
import java.util.Map;

/**
* Factory interface for creating MaintainerExecutor instances. Follows the same pattern as
* OptimizingExecutorFactory.
*
* @param <I> the maintainer input type
*/
public interface MaintainerExecutorFactory<I extends MaintainerInput> extends Serializable {

/**
* Initialize the factory with task properties. Called after constructing the factory through a
* parameterless constructor.
*
* @param properties the task properties
*/
void initialize(Map<String, String> properties);

/**
* Create an executor from the given input.
*
* @param input the maintainer input
* @return the maintainer executor
*/
MaintainerExecutor<?, ?> createExecutor(I input);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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.amoro.maintainer;

import java.io.Serializable;
import java.util.Map;

/**
* Input interface for maintainer operations executed remotely. Follows the same pattern as
* TableOptimizing.OptimizingInput.
*/
public interface MaintainerInput extends Serializable {

/** Maintainer operation type */
enum OperationType {
SNAPSHOT_EXPIRATION,
ORPHAN_FILE_CLEANING,
DANGLING_DELETE_CLEANING,
DATA_EXPIRATION,
TAG_CREATION
}

/**
* Get the operation type for this maintainer task.
*
* @return the operation type
*/
OperationType getOperationType();

/**
* Get the table identifier.
*
* @return table identifier string
*/
String getTableIdentifier();

/**
* Get the table format (ICEBERG, PAIMON, etc.).
*
* @return table format string
*/
String getTableFormat();

/**
* Set an option for this maintainer operation.
*
* @param name option name
* @param value option value
*/
void option(String name, String value);

/**
* Set multiple options for this maintainer operation.
*
* @param options map of option names to values
*/
void options(Map<String, String> options);

/**
* Get all options for this maintainer operation.
*
* @return map of option names to values
*/
Map<String, String> getOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.amoro.maintainer;

import java.io.Serializable;
import java.util.Map;

/**
* Output interface for maintainer operations executed remotely. Follows the same pattern as
* TableOptimizing.OptimizingOutput.
*/
public interface MaintainerOutput extends Serializable {

/**
* Get a summary of the maintainer operation execution.
*
* @return map containing summary information about the operation
*/
Map<String, String> summary();

/**
* Check if the maintainer operation completed successfully.
*
* @return true if operation succeeded, false otherwise
*/
boolean isSuccess();

/**
* Get the error message if the operation failed.
*
* @return error message, or null if operation succeeded
*/
String getErrorMessage();
}
Loading