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

V3 fix storage-http compiler errors #379

Open
wants to merge 60 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8bf26d2
partial migration
gunplar Jul 26, 2024
c1116ad
partial migration
gunplar Jul 26, 2024
588c2c8
partial migration
gunplar Jul 29, 2024
c41a426
Merge branch 'refs/heads/v3' into v3_fix_lib_view
gunplar Jul 29, 2024
eb95f29
partial fix
gunplar Jul 29, 2024
4c73962
partial fix
gunplar Jul 30, 2024
b47e1a7
partial fix
gunplar Jul 30, 2024
7a0060a
partial fix
gunplar Aug 1, 2024
98c8010
partial fix
gunplar Aug 2, 2024
0b8570f
partial fix
gunplar Aug 2, 2024
cafdf59
partial work
gunplar Aug 7, 2024
f1c3095
Merge branch 'refs/heads/v3' into v3_fix_lib_view
gunplar Aug 7, 2024
a418ab2
partial fix
gunplar Aug 9, 2024
3af5570
partial fix
gunplar Aug 9, 2024
92670ae
partial fix
gunplar Aug 9, 2024
b11d854
partial fix
gunplar Aug 12, 2024
63c9c09
partial fix
gunplar Aug 12, 2024
ad35da6
partial fix
gunplar Aug 12, 2024
9520817
partial fix
gunplar Aug 13, 2024
30a487e
Merge branch 'refs/heads/v3' into v3_fix_lib_view
gunplar Aug 13, 2024
99158e5
partial fix
gunplar Aug 13, 2024
68929c6
partial fix
gunplar Aug 13, 2024
ec8baa6
partial fix
gunplar Aug 13, 2024
0fc0549
partial fix
gunplar Aug 13, 2024
4d6384a
partial fix
gunplar Aug 13, 2024
dd4c36a
partial fix
gunplar Aug 14, 2024
6336942
partial fix
gunplar Aug 14, 2024
3ac90be
bug fix
gunplar Aug 16, 2024
412ea12
Merge branch 'refs/heads/v3' into v3_fix_lib_view
gunplar Aug 19, 2024
cb0b089
partial fix
gunplar Aug 19, 2024
a75132a
partial fix
gunplar Aug 21, 2024
5bb53aa
partial fix
gunplar Aug 22, 2024
0eefe27
partial fix
gunplar Aug 22, 2024
34fbeec
partial fix
gunplar Aug 23, 2024
bc84efa
partial fix
gunplar Aug 26, 2024
d2537dd
partial fix
gunplar Aug 26, 2024
64befaf
partial fix
gunplar Aug 26, 2024
e02da89
partial fix
gunplar Aug 27, 2024
0708ab1
partial fix
gunplar Aug 29, 2024
77e65d5
Merge branch 'refs/heads/v3' into v3_fix_lib_view
gunplar Aug 29, 2024
7a66c3b
partial fix
gunplar Aug 29, 2024
7fa877a
Merge branch 'refs/heads/v3_fix_lib_view' into v3_fix_storage_http
gunplar Aug 29, 2024
0f4297e
partial fix
gunplar Aug 29, 2024
11ed287
partial fix
gunplar Sep 2, 2024
135bd51
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Sep 3, 2024
7b3ab7a
partial fix
gunplar Sep 3, 2024
c23b933
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Sep 3, 2024
25739d8
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Sep 3, 2024
49018b8
partial fix
gunplar Sep 5, 2024
c241282
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Sep 10, 2024
f5f67af
Merge remote-tracking branch 'origin/v3' into v3_fix_storage_http
gunplar Oct 31, 2024
a62f935
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Nov 7, 2024
c48af60
Merge remote-tracking branch 'origin/v3' into v3_fix_storage_http
gunplar Nov 7, 2024
250e78d
WIP
gunplar Nov 8, 2024
1244ce5
WIP
gunplar Nov 11, 2024
e538d28
Merge branch 'refs/heads/v3' into v3_fix_storage_http
gunplar Nov 11, 2024
ce1c66d
WIP
gunplar Nov 12, 2024
c1a2406
enable tests on cicd for storage-http
gunplar Nov 12, 2024
43c8079
WIP
gunplar Nov 12, 2024
8b0b55c
trigger cicd to make sure it is not affected by pipeline definition f…
gunplar Nov 12, 2024
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 .github/workflows/reusable-build-and-publish-v3s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# run: gradle shadowJar jacocoTestReport jacocoTestCoverageVerification
shell: bash
run: |
array=( here-naksha-lib-model here-naksha-lib-base here-naksha-lib-core here-naksha-lib-psql here-naksha-lib-view )
array=( here-naksha-lib-model here-naksha-lib-base here-naksha-lib-core here-naksha-lib-psql here-naksha-lib-view here-naksha-storage-http )
for item in ${array[@]}; do
gradle -x jsNodeTest :$item:build :$item:jacocoTestReport :$item:jacocoTestCoverageVerification
done
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package naksha.base

class JvmProxyUtil {
companion object {
@JvmStatic
fun <T: Proxy> box(raw: Any?, _clazz: Class<T>): T? =
Proxy.box(raw, _clazz.kotlin)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package naksha.model.request

import naksha.base.NotNullProperty
import naksha.base.NullableProperty
import naksha.model.objects.NakshaFeature
import naksha.model.objects.NakshaFeatureList
import kotlin.js.JsExport
import kotlin.js.JsName
Expand All @@ -30,6 +31,11 @@ open class SuccessResponse @Deprecated("Use secondary", ReplaceWith("SuccessResp
this.features.addAll(tuples.map { it.feature })
}

@JsName("ofFeatures")
constructor(features: NakshaFeatureList) : this() {
this.features.addAll(features)
}

companion object SuccessResponse_C {
private val RESULT_SET_NULL = NullableProperty<SuccessResponse, IResultSet>(IResultSet::class)
private val TUPLES = NotNullProperty<SuccessResponse, ResultTupleList>(ResultTupleList::class) { self, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ class PAnd() : ListProxy<IPropertyQuery>(IPropertyQuery::class), IPropertyQuery
constructor(vararg queries: IPropertyQuery) : this() {
addAll(queries)
}

override fun toString(): String {
return joinToString("&")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ import kotlin.js.JsName
class POr() : ListProxy<IPropertyQuery>(IPropertyQuery::class), IPropertyQuery {

/**
* Create a logical AND combination of the given queries.
* Create a logical OR combination of the given queries.
* @param queries the queries to combine.
*/
@JsName("of")
constructor(vararg queries: IPropertyQuery) : this() {
addAll(queries)
}

override fun toString(): String {
//TODO will not work like expected key=val1,val2, rather currently it is key1=val1,key2=val2
return joinToString(",")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ open class PQuery() : AnyObject(), IPropertyQuery {
* The parameter value of the operation; if any.
*/
var value by ANY
// TODO
// override fun toString(): String {
//
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,62 +206,75 @@ private boolean isRequestOnlyById(ReadRequest request) {

@Override
public int getSocketTimeout() {
//TODO
return 0;
}

@Override
public void setSocketTimeout(int i) {}
public void setSocketTimeout(int i) {
//TODO
}

@Override
public int getStmtTimeout() {
return 0;
return 0; //TODO
}

@Override
public void setStmtTimeout(int i) {}
public void setStmtTimeout(int i) { //TODO
}

@Override
public int getLockTimeout() {
return 0;
return 0; //TODO

}

@Override
public void setLockTimeout(int i) {}
public void setLockTimeout(int i) { //TODO
}

@Override
public boolean isClosed() {
return false;
return false; //TODO

}

@NotNull
@Override
public String getMap() {
return "";
return ""; //TODO

}

@Override
public void setMap(@NotNull String s) {}
public void setMap(@NotNull String s) { //TODO
}

@Override
public boolean validateHandle(@NotNull String handle, @Nullable Integer ttl) {
return false;
return false; //TODO

}

@NotNull
@Override
public Response executeParallel(@NotNull Request request) {
return execute(request);
return execute(request); //TODO

}

@NotNull
@Override
public List<Tuple> getTuples(@NotNull TupleNumber[] tupleNumbers, boolean fetchFromHistory, int mode) {
return List.of();
return List.of(); //TODO

}

@Override
public void fetchTuples(
@NotNull List<? extends ResultTuple> resultTuples, int from, int to, boolean fetchFromHistory, int mode) {}
@NotNull List<? extends ResultTuple> resultTuples, int from, int to, boolean fetchFromHistory, int mode) { //TODO
}

@Override
public @NotNull Transaction transaction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
*/
package com.here.naksha.storage.http;

import static com.here.naksha.storage.http.RequestSender.KeyProperties;

import com.here.naksha.lib.core.lambdas.Fe1;
import com.here.naksha.lib.core.models.naksha.Storage;
import com.here.naksha.lib.core.util.json.JsonSerializable;
import com.here.naksha.storage.http.RequestSender.KeyProperties;
import com.here.naksha.storage.http.cache.RequestSenderCache;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import naksha.model.IReadSession;
import naksha.model.IStorage;
import naksha.model.NakshaContext;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import naksha.base.Int64;
import naksha.base.JvmProxyUtil;
import naksha.model.*;
import naksha.model.objects.NakshaFeature;
import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand All @@ -40,8 +39,17 @@ public class HttpStorage implements IStorage {

private final RequestSender requestSender;

private final AtomicBoolean initialized = new AtomicBoolean(false);

public HttpStorage(@NotNull Storage storage) {
HttpStorageProperties properties = HttpStorage.getProperties(storage);
if (properties == null) {
if (!storage.getProperties().hasRaw(HttpStorageProperties.URL)) {
throw new IllegalArgumentException("A HTTP storage must have properties containing a 'url'");
}
properties = new HttpStorageProperties(
storage.getProperties().get(HttpStorageProperties.URL).toString(), null, null, null);
}
requestSender = RequestSenderCache.getInstance()
.getSenderWith(new KeyProperties(
storage.getId(),
Expand All @@ -51,31 +59,117 @@ public HttpStorage(@NotNull Storage storage) {
properties.getSocketTimeout()));
}

@Override
public @NotNull IReadSession newReadSession(@Nullable NakshaContext context, boolean useMaster) {
return new HttpStorageReadSession(context, useMaster, requestSender);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method is no longer used in Handlers or Tasks it can be removed completely

}

private static @Nullable HttpStorageProperties getProperties(@NotNull Storage storage) {
return JvmProxyUtil.box(storage.getProperties(), HttpStorageProperties.class);
}

@Override
public void close() {
// TODO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything that should be closed or finalized inside HttpStorage.
So if there is no additional requirement from Naksha design to handle closure in some particular way, I think //TODO here is not needed

}

@NotNull
@Override
public IReadSession newReadSession(@Nullable SessionOptions options) {
boolean useMaster = false;
if (options != null) {
requestSender.keyProps.connectionTimeoutSec = options.connectTimeout;
requestSender.keyProps.socketTimeoutSec = options.socketTimeout;
useMaster = options.useMaster;
}
return new HttpStorageReadSession(NakshaContext.currentContext(), useMaster, requestSender);
}

@NotNull
@Override
public void initStorage() {
public IWriteSession newWriteSession(@Nullable SessionOptions options) {
// TODO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write session is not supported in HttpStorage, so there is no need for //TODO
It will be supported when the DataHub Connector HttpStorage is implemented, but it is not ready and I guess migrating it to v3 will be whole another task.

throw new NotImplementedException("Not yet supported");
}

@Nullable
@Override
public String getMapId(int mapNumber) {
throw new NotImplementedException("Not supported for HTTP storage");
}

@Override
public boolean contains(@NotNull String mapId) {
throw new NotImplementedException("Not supported for HTTP storage");
}

@NotNull
@Override
public IMap get(@NotNull String mapId) {
throw new NotImplementedException("Not supported for HTTP storage");
}

@NotNull
@Override
public IMap getDefaultMap() {
throw new NotImplementedException("Not supported for HTTP storage");
}

@Override
public void initStorage(@Nullable Map<String, ?> params) {
log.debug("HttpStorage.initStorage called");
initialized.set(true);
// TODO processing params when needed
}

@Override
public void startMaintainer() {}
public boolean isInitialized() {
return initialized.get();
}

@NotNull
@Override
public void maintainNow() {}
public SessionOptions getAdminOptions() {
throw new NotImplementedException("Not supported for HTTP storage");
}

@NotNull
@Override
public void stopMaintainer() {}
public String getId() {
return requestSender.keyProps.getName();
}

@NotNull
@Override
public @NotNull <T> Future<T> shutdown(@Nullable Fe1<T, IStorage> onShutdown) {
return new FutureTask<>(() -> onShutdown != null ? onShutdown.call(this) : null);
public NakshaFeature tupleToFeature(@NotNull Tuple tuple) {
throw new NotImplementedException("Not supported for HTTP storage");
}

private static @NotNull HttpStorageProperties getProperties(@NotNull Storage storage) {
return JsonSerializable.convert(storage.getProperties(), HttpStorageProperties.class);
@NotNull
@Override
public Tuple featureToTuple(@NotNull NakshaFeature feature) {
throw new NotImplementedException("Not supported for HTTP storage");
}

@NotNull
@Override
public ILock enterLock(@NotNull String id, @NotNull Int64 waitMillis) {
throw new NotImplementedException("Enter lock not supported");
}

@Override
public int getHardCap() {
throw new NotImplementedException("Not supported for HTTP storage");
}

@Override
public void setHardCap(int i) {
throw new NotImplementedException("Not supported for HTTP storage");
}

@Nullable
@Override
public IMap get(int mapNumber) {
throw new NotImplementedException("Not supported for HTTP storage");
}

}
Loading
Loading