-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: v3
Are you sure you want to change the base?
Changes from all commits
8bf26d2
c1116ad
588c2c8
c41a426
eb95f29
4c73962
b47e1a7
7a0060a
98c8010
0b8570f
cafdf59
f1c3095
a418ab2
3af5570
92670ae
b11d854
63c9c09
ad35da6
9520817
30a487e
99158e5
68929c6
ec8baa6
0fc0549
4d6384a
dd4c36a
6336942
3ac90be
412ea12
cb0b089
a75132a
5bb53aa
0eefe27
34fbeec
bc84efa
d2537dd
64befaf
e02da89
0708ab1
77e65d5
7a66c3b
7fa877a
0f4297e
11ed287
135bd51
7b3ab7a
c23b933
25739d8
49018b8
c241282
f5f67af
a62f935
c48af60
250e78d
1244ce5
e538d28
ce1c66d
c1a2406
43c8079
8b0b55c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -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; | ||
|
@@ -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(), | ||
|
@@ -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); | ||
} | ||
|
||
private static @Nullable HttpStorageProperties getProperties(@NotNull Storage storage) { | ||
return JvmProxyUtil.box(storage.getProperties(), HttpStorageProperties.class); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
@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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
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"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
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