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

docker: added dockerfile for build in ubuntu22. #2858

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .obm.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
container_name: curve-build-playground.master
container_image: opencurvedocker/curve-base:build-debian11
container_image: opencurvedocker/curve-build:ubuntu22
6 changes: 3 additions & 3 deletions curvefs/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ How to build

``` bash
$ git clone [email protected]:opencurve/curve.git
$ cd curve
$ make dep stor=fs
$ make playground
$ make ci-dep stor=fs
$ make sdk
```

It will generate a jar after build success:
It will generate a jar package after build success:

```
Build SDK success => /curve/curvefs/sdk/output/curvefs-hadoop-1.0-SNAPSHOT.jar
Expand Down
2 changes: 2 additions & 0 deletions curvefs/sdk/java/native/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ cc_binary(
copts = CURVE_DEFAULT_COPTS,
linkopts = [
"-Wl,-rpath=/tmp/libcurvefs,--disable-new-dtags",
"-L/usr/lib/x86_64-linux-gnu/",
"-lhashkit",
],
deps = [
"@com_google_absl//absl/cleanup",
Expand Down
24 changes: 24 additions & 0 deletions curvefs/sdk/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,34 @@
<resource>
<directory>native/build</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>

<plugins>
<!-- any other plugins -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.opencurve.curve.fs.common;

import java.text.SimpleDateFormat;
import java.util.Date;

public class StackLogger {
private String classname;
private int level;

private static final String CURVEFS_DEBUG_ENV_VAR = "CURVEFS_DEBUG";

public StackLogger(String classname, int level) {
this.classname = classname;
this.level = level;
}

private String now() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return formatter.format(new Date());
}

//private int getIndex() {
// long id = Thread.currentThread().getId();
//}

public void log(String fn, Object... args) {
String value = System.getenv(CURVEFS_DEBUG_ENV_VAR);
if (!Boolean.valueOf(value)) {
return;
}

String[] params = new String[args.length];
for (int i = 0; i < args.length; i++) {
params[i] = args[i].toString();
}

String indent = " ".repeat(this.level * 4);
String param = String.join(",", params);
String message = String.format("+ [%s] %s%s.%s(%s)", now(), indent, this.classname, fn, param);
System.out.println(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.opencurve.curve.fs.flink;

import io.opencurve.curve.fs.common.StackLogger;
import io.opencurve.curve.fs.hadoop.CurveFileSystem;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.FileSystemFactory;
Expand All @@ -11,32 +12,25 @@

public class CurveFileSystemFactory implements FileSystemFactory {
private org.apache.hadoop.conf.Configuration conf;

private static final String CURVE_FS_CONFIG_PREFIXES = "curvefs.";
private static final String FLINK_CONFIG_PREFIXES = "fs.";
public static String SCHEME = "curvefs";
private static final StackLogger logger =
new StackLogger("CurveFileSystemFactory", 0);

@Override
public void configure(org.apache.flink.configuration.Configuration config) {
conf = new Configuration();
if (config != null) {
for (String key : config.keySet()) {
if (key.startsWith(CURVE_FS_CONFIG_PREFIXES) || key.startsWith(FLINK_CONFIG_PREFIXES)) {
String value = config.getString(key, null);
if (value != null) {
if (CurveFileSystem.class.getCanonicalName().equals(value.trim())) {
SCHEME = key.split("\\.")[1];
}
conf.set(key, value);
}
}
}
}
config.keySet()
.stream()
.filter(key -> key.startsWith(CURVE_FS_CONFIG_PREFIXES) || key.startsWith(FLINK_CONFIG_PREFIXES))
.forEach(key -> conf.set(key, config.getString(key, "")));
}

@Override
public String getScheme() {
return SCHEME;
logger.log("getScheme");
return "hdfs";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSInputStream;
import io.opencurve.curve.fs.libfs.CurveFSMount;
import io.opencurve.curve.fs.common.StackLogger;

import java.io.IOException;

Expand All @@ -37,6 +38,7 @@
*/
public class CurveFSInputStream extends FSInputStream {
private static final Log LOG = LogFactory.getLog(CurveFSInputStream.class);
private static final StackLogger logger = new StackLogger("CurveFSInputStream", 0);
private boolean closed;

private int fileHandle;
Expand All @@ -59,21 +61,25 @@ public class CurveFSInputStream extends FSInputStream {
*/
public CurveFSInputStream(Configuration conf, CurveFSProto curvefs,
int fh, long flength, int bufferSize) {
// Whoever's calling the constructor is responsible for doing the actual curve_open
// call and providing the file handle.
fileLength = flength;
fileHandle = fh;
closed = false;
curve = curvefs;
buffer = new byte[1<<21];
LOG.debug("CurveInputStream constructor: initializing stream with fh "
+ fh + " and file length " + flength);
logger.log("CurveFSInputStream");

// Whoever's calling the constructor is responsible for doing the actual curve_open
// call and providing the file handle.
fileLength = flength;
fileHandle = fh;
closed = false;
curve = curvefs;
buffer = new byte[1<<21];
LOG.debug("CurveInputStream constructor: initializing stream with fh "
+ fh + " and file length " + flength);
}

/** Curve likes things to be closed before it shuts down,
* so closing the IOStream stuff voluntarily in a finalizer is good
*/
protected void finalize() throws Throwable {
logger.log("finalize");

try {
if (!closed) {
close();
Expand All @@ -84,6 +90,8 @@ protected void finalize() throws Throwable {
}

private synchronized boolean fillBuffer() throws IOException {
logger.log("fillBuffer");

bufValid = curve.read(fileHandle, buffer, buffer.length, -1);
bufPos = 0;
if (bufValid < 0) {
Expand Down Expand Up @@ -118,6 +126,8 @@ public synchronized int available() throws IOException {
}

public synchronized void seek(long targetPos) throws IOException {
logger.log("seek", targetPos);

LOG.trace("CurveInputStream.seek: Seeking to position " + targetPos + " on fd "
+ fileHandle);
if (targetPos > fileLength) {
Expand All @@ -143,6 +153,7 @@ public synchronized void seek(long targetPos) throws IOException {
* @return false.
*/
public synchronized boolean seekToNewSource(long targetPos) {
logger.log("seekToNewSource", targetPos);
return false;
}

Expand All @@ -152,6 +163,7 @@ public synchronized boolean seekToNewSource(long targetPos) {
*/
@Override
public synchronized int read() throws IOException {
logger.log("read");
LOG.trace(
"CurveInputStream.read: Reading a single byte from fd " + fileHandle
+ " by calling general read function");
Expand Down Expand Up @@ -183,6 +195,8 @@ public synchronized int read() throws IOException {
*/
@Override
public synchronized int read(byte buf[], int off, int len) throws IOException {
logger.log("read", off, len);

LOG.trace(
"CurveInputStream.read: Reading " + len + " bytes from fd " + fileHandle);

Expand Down Expand Up @@ -241,6 +255,8 @@ public synchronized int read(byte buf[], int off, int len) throws IOException {
*/
@Override
public void close() throws IOException {
logger.log("close");

LOG.trace("CurveOutputStream.close:enter");
if (!closed) {
curve.close(fileHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

package io.opencurve.curve.fs.hadoop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import io.opencurve.curve.fs.common.StackLogger;
import io.opencurve.curve.fs.libfs.CurveFSMount;

import java.io.IOException;
Expand All @@ -42,6 +41,8 @@
* much more.
*/
public class CurveFSOutputStream extends OutputStream {
private static final StackLogger logger = new StackLogger("CurveFSOutputStream", 0);

private boolean closed;

private CurveFSProto curve;
Expand All @@ -58,6 +59,7 @@ public class CurveFSOutputStream extends OutputStream {
*/
public CurveFSOutputStream(Configuration conf, CurveFSProto curvefs,
int fh, int bufferSize) {
logger.log("CurveFSOutputStream", fh, bufferSize);
curve = curvefs;
fileHandle = fh;
closed = false;
Expand All @@ -68,6 +70,8 @@ public CurveFSOutputStream(Configuration conf, CurveFSProto curvefs,
* Close the Curve file handle if close() wasn't explicitly called.
*/
protected void finalize() throws Throwable {
logger.log("finalize");

try {
if (!closed) {
close();
Expand All @@ -91,19 +95,23 @@ private synchronized void checkOpen() throws IOException {
* @return The file offset in bytes.
*/
public synchronized long getPos() throws IOException {
logger.log("getPos");
checkOpen();
return curve.lseek(fileHandle, 0, CurveFSMount.SEEK_CUR);
}

@Override
public synchronized void write(int b) throws IOException {
logger.log("write", b);

byte buf[] = new byte[1];
buf[0] = (byte) b;
write(buf, 0, 1);
}

@Override
public synchronized void write(byte buf[], int off, int len) throws IOException {
logger.log("write", off, len);
checkOpen();

while (len > 0) {
Expand Down Expand Up @@ -159,13 +167,16 @@ private synchronized void flushBuffer() throws IOException {

@Override
public synchronized void flush() throws IOException {
logger.log("flush");

checkOpen();
flushBuffer(); // buffer -> libcurvefs
curve.fsync(fileHandle); // libcurvefs -> cluster
}

@Override
public synchronized void close() throws IOException {
logger.log("close");
checkOpen();
flush();
curve.close(fileHandle);
Expand Down
Loading