Skip to content
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 @@ -36,6 +36,7 @@ import org.apache.texera.dao.jooq.generated.tables.daos.{
WorkflowUserAccessDao
}
import org.apache.texera.dao.jooq.generated.tables.pojos._
import org.apache.texera.service.util.BigObjectManager
import org.apache.texera.web.resource.dashboard.hub.EntityType
import org.apache.texera.web.resource.dashboard.hub.HubResource.recordCloneAction
import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowAccessResource.hasReadAccess
Expand Down Expand Up @@ -600,6 +601,8 @@ class WorkflowResource extends LazyLogging {
.asScala
.toList

BigObjectManager.deleteAllObjects()

// Collect all URIs related to executions for cleanup
val uris = eids.flatMap { eid =>
val executionId = ExecutionIdentity(eid.longValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.apache.amber.engine.architecture.worker.WorkflowWorker.{
}
import org.apache.amber.error.ErrorUtils.{getOperatorFromActorIdOpt, getStackTraceWithAllCauses}
import org.apache.texera.dao.jooq.generated.tables.pojos.User
import org.apache.texera.service.util.BigObjectManager
import org.apache.texera.web.model.websocket.event.TexeraWebSocketEvent
import org.apache.texera.web.model.websocket.request.WorkflowExecuteRequest
import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowExecutionsResource
Expand Down Expand Up @@ -307,6 +308,7 @@ class WorkflowService(
* 2. Clears URI references from the execution registry
* 3. Safely clears all result and console message documents
* 4. Expires Iceberg snapshots for runtime statistics
* 5. Deletes big objects from MinIO
*
* @param eid The execution identity to clean up resources for
*/
Expand Down Expand Up @@ -343,6 +345,7 @@ class WorkflowService(
logger.debug(s"Error processing document at $uri: ${error.getMessage}")
}
}
// Delete big objects
BigObjectManager.deleteAllObjects()
}

}
13 changes: 11 additions & 2 deletions common/workflow-core/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ Test / PB.protoSources += PB.externalSourcePath.value
// Test-related Dependencies
/////////////////////////////////////////////////////////////////////////////

val testcontainersVersion = "0.43.0"

libraryDependencies ++= Seq(
"org.scalamock" %% "scalamock" % "5.2.0" % Test, // ScalaMock
"org.scalatest" %% "scalatest" % "3.2.15" % Test, // ScalaTest
"junit" % "junit" % "4.13.2" % Test, // JUnit
"com.novocode" % "junit-interface" % "0.11" % Test // SBT interface for JUnit
"com.novocode" % "junit-interface" % "0.11" % Test, // SBT interface for JUnit
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersVersion % Test, // Testcontainers ScalaTest integration
"com.dimafeng" %% "testcontainers-scala-minio" % testcontainersVersion % Test // MinIO Testcontainer Scala integration
)


Expand Down Expand Up @@ -183,5 +187,10 @@ libraryDependencies ++= Seq(
"org.apache.commons" % "commons-vfs2" % "2.9.0", // for FileResolver throw VFS-related exceptions
"io.lakefs" % "sdk" % "1.51.0", // for lakeFS api calls
"com.typesafe" % "config" % "1.4.3", // config reader
"org.apache.commons" % "commons-jcs3-core" % "3.2" // Apache Commons JCS
"org.apache.commons" % "commons-jcs3-core" % "3.2", // Apache Commons JCS
"software.amazon.awssdk" % "s3" % "2.29.51" excludeAll(
ExclusionRule(organization = "io.netty")
),
"software.amazon.awssdk" % "auth" % "2.29.51",
"software.amazon.awssdk" % "regions" % "2.29.51",
)
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public enum AttributeType implements Serializable {
BOOLEAN("boolean", Boolean.class),
TIMESTAMP("timestamp", Timestamp.class),
BINARY("binary", byte[].class),
BIG_OBJECT("big_object", BigObject.class),
ANY("ANY", Object.class);

private final String name;
Expand Down Expand Up @@ -109,6 +110,8 @@ public static AttributeType getAttributeType(Class<?> fieldClass) {
return TIMESTAMP;
} else if (fieldClass.equals(byte[].class)) {
return BINARY;
} else if (fieldClass.equals(BigObject.class)) {
return BIG_OBJECT;
} else {
return ANY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ object AttributeTypeUtils extends Serializable {
): Any = {
if (field == null) return null
attributeType match {
case AttributeType.INTEGER => parseInteger(field, force)
case AttributeType.LONG => parseLong(field, force)
case AttributeType.DOUBLE => parseDouble(field)
case AttributeType.BOOLEAN => parseBoolean(field)
case AttributeType.TIMESTAMP => parseTimestamp(field)
case AttributeType.STRING => field.toString
case AttributeType.BINARY => field
case AttributeType.ANY | _ => field
case AttributeType.INTEGER => parseInteger(field, force)
case AttributeType.LONG => parseLong(field, force)
case AttributeType.DOUBLE => parseDouble(field)
case AttributeType.BOOLEAN => parseBoolean(field)
case AttributeType.TIMESTAMP => parseTimestamp(field)
case AttributeType.STRING => field.toString
case AttributeType.BINARY => field
case AttributeType.BIG_OBJECT => new BigObject(field.toString)
case AttributeType.ANY | _ => field
}
}

Expand Down Expand Up @@ -383,7 +384,9 @@ object AttributeTypeUtils extends Serializable {
case AttributeType.INTEGER => tryParseInteger(fieldValue)
case AttributeType.TIMESTAMP => tryParseTimestamp(fieldValue)
case AttributeType.BINARY => tryParseString()
case _ => tryParseString()
case AttributeType.BIG_OBJECT =>
AttributeType.BIG_OBJECT // Big objects are never inferred from data
case _ => tryParseString()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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.amber.core.tuple;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.amber.core.executor.OperatorExecutor;
import org.apache.texera.service.util.BigObjectManager;

import java.net.URI;
import java.util.Objects;

/**
* BigObject represents a reference to a large object stored in S3.
*
* Each BigObject is identified by an S3 URI (s3://bucket/path/to/object).
* BigObjects are automatically tracked and cleaned up when the workflow execution completes.
*/
public class BigObject {

private final String uri;

/**
* Creates a BigObject from an existing S3 URI.
* Used primarily for deserialization from JSON.
*
* @param uri S3 URI in the format s3://bucket/path/to/object
* @throws IllegalArgumentException if URI is null or doesn't start with "s3://"
*/
@JsonCreator
public BigObject(@JsonProperty("uri") String uri) {
if (uri == null) {
throw new IllegalArgumentException("BigObject URI cannot be null");
}
if (!uri.startsWith("s3://")) {
throw new IllegalArgumentException(
"BigObject URI must start with 's3://', got: " + uri
);
}
this.uri = uri;
}

/**
* Creates a new BigObject for writing data.
* Generates a unique S3 URI.
*
* Usage example:
*
* BigObject bigObject = new BigObject();
* try (BigObjectOutputStream out = new BigObjectOutputStream(bigObject)) {
* out.write(data);
* }
* // bigObject is now ready to be added to tuples
*
*/
public BigObject() {
this(BigObjectManager.create());
}

@JsonValue
public String getUri() {
return uri;
}

public String getBucketName() {
return URI.create(uri).getHost();
}

public String getObjectKey() {
String path = URI.create(uri).getPath();
return path.startsWith("/") ? path.substring(1) : path;
}

@Override
public String toString() {
return uri;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof BigObject)) return false;
BigObject that = (BigObject) obj;
return Objects.equals(uri, that.uri);
}

@Override
public int hashCode() {
return Objects.hash(uri);
}
}
Loading
Loading