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

Unified interface #356

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Unified interface #356

wants to merge 8 commits into from

Conversation

morrowgi
Copy link
Collaborator

@morrowgi morrowgi commented Jul 3, 2017

No description provided.

@morrowgi
Copy link
Collaborator Author

morrowgi commented Jul 3, 2017

Implementing #355

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we keeping these kind of comments in micro-server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

woops will remove...

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aol.micro.server.distributed.DistributedMap;
import com.couchbase.client.CouchbaseClient;

@Slf4j
public class CouchbaseDistributedMapClient<V> implements DistributedMap<V> {

private final Logger logger = LoggerFactory.getLogger(getClass());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessary when you have the lombok @slf4j annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot thanks

@@ -45,15 +45,26 @@
@Value("${couchbaseClientOperationTimeout:120000}")
private long opTimeout;

@Value("${distributed.cache.default.expiration:691200}")
private int expiresAfterSeconds = 691200;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't need to assign this value will be overwritten by Spring annotation same for line 52,55

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok removed the assignment


} catch (final Exception e) {

log.warn("memcache put: {}", e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you mean couchbase instead of memcache ?

private ElasticacheConnectionTester elasticacheConnectionTester;


@Scheduled(fixedDelay = 60000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe expose this as a property ? but have it default to 60000

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed as @scheduled expects a constant I needed to assign it directly in code

try {
result = testConnection();
} catch (RuntimeException e) {
log.debug("Could not connect to Cache" + e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this log at the right level ? also line 41

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was keeping the convention as it was but I think you are right I will log as error if it cannot connect...


private final String key;

private volatile Xor<Void, T> data = Xor.secondary(null); // Void represents
Copy link
Collaborator

@tonyfinn tonyfinn Jul 3, 2017

Choose a reason for hiding this comment

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

Why Xor<Void, T> over just Optional<T>? Or if you're worried about the loaded/not loaded yet case seperately, Future<Optional<T>> ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok I think I can convert to Optional

return currentVersionedKey.withVersion(currentVersionedKey.getVersion() + 1);
}

private VersionedKey loadKeyFromCouchbase() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not coming from Couchbase here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Il update


import java.util.Optional;

public interface DistributedCache<V> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you inherit DistributedMap here?

@@ -20,11 +21,11 @@
@Rest
public class CouchbaseResource {

private final DistributedMap client;
private final DistributedCache client;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd change the reference name as well 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants