I want to create an abstract repository to a federated store in AllegroGraph.
I can connect to the repositories stored on different server. But when I try to combine them using federate function, it throws an error that it cannot find the repository on the second server.
I found the same question in this link but it doesn't help. Any hints?
This is my code:
AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
println("Available catalogs: " + server.listCatalogs());
AGRepositoryConnection custCon = server.createRepositoryConnection("repo1", CATALOG_ID, false);
AGRepositoryConnection supCon = server2.createRepositoryConnection("repo2", CATALOG_ID, false);
AGAbstractRepository rainbowRepo = server2.federate(custCon.getRepository(), supCon.getRepository());
rainbowRepo.initialize();
AGRepositoryConnection rainbowConn = rainbowRepo.getConnection();
SailRepository class implements FederatedServiceResolverClient for the federation context, so u can use the class SailRepository to add a federated store with different repositories :
AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
AGRepository repo1 = server.getCatalog(CATALOG_ID).openRepository("repo1");
AGRepository repo2 = server2.getCatalog(CATALOG_ID).openRepository("repo2");
Federation federation = new Federation();
federation.addMember(repo1);
federation.addMember(repo2);
federation.setReadOnly(true);
SailRepository rainbowRepo = new SailRepository(federation);
rainbowRepo .initialize();
SailRepositoryConnection rainbowConn = rainbowRepo .getConnection(); //for querying and updating the contents of the repository.
Related
I have a servers file on my computer with http-auth-types = Negotiate;ntlm;basic
The following Java program with svnkit 1.10.2 should connect to a repository :
public static void main(String[] args) throws SVNException
{
SVNClientManager clientManager = SVNClientManager.newInstance();
ISVNAuthenticationManager manager = SVNWCUtil.createDefaultAuthenticationManager();
clientManager.setAuthenticationManager(manager);
SVNURL repositoryURL = SVNURL.parseURIEncoded(args[0]);
SVNRepository repository = clientManager.createRepository(repositoryURL, true);
Collection<SVNDirEntry> contentOfFolder = repository.getDir("", SVNRevision.HEAD.getNumber(),
null, SVNDirEntry.DIRENT_ALL, (Collection<SVNDirEntry>) null);
System.out.println(contentOfFolder);
}
Unfortunately, I get
org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication required for ...
What am I doing wrong? Do I somehow need to tell svnkit to use ntlm?
I have following code.
String orientDBPath = "memory:visdb";
ODatabaseObjectPool objectPool;
OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();
objectPool = new ODatabaseObjectPool(orientDBPath, username, password, dbConfig);
When I'm acquiring ODatabaseObject with objectPool.acquire(), I receive following ODatabaseException.
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: OrientDB instanced created without physical path, only memory databases are allowed
DB name="visdb"
at com.orientechnologies.orient.core.db.OrientDBEmbedded.buildName(OrientDBEmbedded.java:186)
at com.orientechnologies.orient.core.db.OrientDBEmbedded.getOrInitStorage(OrientDBEmbedded.java:173)
at com.orientechnologies.orient.core.db.OrientDBEmbedded.poolOpen(OrientDBEmbedded.java:159)
at com.orientechnologies.orient.core.db.ODatabasePoolImpl$1.createNewResource(ODatabasePoolImpl.java:40)
at com.orientechnologies.orient.core.db.ODatabasePoolImpl$1.createNewResource(ODatabasePoolImpl.java:37)
at com.orientechnologies.common.concur.resource.OResourcePool.getResource(OResourcePool.java:95)
at com.orientechnologies.orient.core.db.ODatabasePoolImpl.acquire(ODatabasePoolImpl.java:59)
at com.orientechnologies.orient.core.db.ODatabasePool.acquire(ODatabasePool.java:132)
at com.orientechnologies.orient.object.db.ODatabaseObjectPool.acquire(ODatabaseObjectPool.java:40)
What is the correct way to initialize ODatabaseObjectPool and ODatabasePool for memory DB?
I do use in-memory graph in my unit tests. Here is how I create the pool
String orientDBPath = "memory:visdb";
OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();
OrientDB orientDB = new OrientDB(orientDBPath, dbConfig);
orientDB.createIfNotExists(orientDBPath, ODatabaseType.MEMORY);
ODatabasePool pool = new ODatabasePool(orientDB, orientDBPath, "admin",
"admin");
ODatabaseSession session = pool.acquire();
// later
session.close();
pool.close();
orientDB.close();
Depentency:
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-client</artifactId>
<version>3.0.4</version>
</dependency>
Hope it helps.
I found another solution which worked for me.
OrientDBConfig dbConfig = OrientDBConfig.defaultConfig();
ODatabasePoolInternal documentPoolInternal;
OrientDBEmbedded orientDBEmbedded = new OrientDBEmbedded("", dbConfig, Orient.instance());
orientDBEmbedded.create(orientDBName, username, password, ODatabaseType.MEMORY, dbConfig);
documentPoolInternal = orientDBEmbedded.openPool(orientDBName, username, password);
ODatabaseSession session = documentPoolInternal.acquire();
I'm trying to create a new AWS EC2 instance using the AWS Java SDK but getting "Value () for parameter groupId is invalid. The value cannot be empty". Here is my code:
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
ec2 = AmazonEC2ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(Regions.US_WEST_2)
.build();
}
RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
String ami_id = "ami-efd0428f"; //ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170414
Collection<String> securityGroups = new ArrayList<>();
securityGroups.add("launch-wizard-1");
securityGroups.add("sg-9405c2f3");
runInstancesRequest.withImageId(ami_id)
.withInstanceType("t2.medium")
.withMinCount(1)
.withMaxCount(1)
.withKeyName("MyKeyName")
.withSecurityGroups(securityGroups);
RunInstancesResult run_response = ec2.runInstances(runInstancesRequest); // fails here!
String instance_id = run_response.getReservation().getReservationId();
Tag tag = new Tag()
.withKey("Name")
.withValue(tfCompanyName.getText());
Collection<Tag> tags = new ArrayList<>();
tags.add(tag);
CreateTagsRequest tag_request = new CreateTagsRequest();
tag_request.setTags(tags);
CreateTagsResult tag_response = ec2.createTags(tag_request);
String s = String.format("Successfully started EC2 instance %s based on AMI %s",instance_id, ami_id);
System.out.println(s);
Any suggestions?
You might need to add a VPC details also .
PrivateIpAddresses ,Monitoring are among other required fields.
I would recommend you to try creating EC2 Instance manually using AWS Console and see what are the required parameters it is asking?
I'm trying to fetch unread messages from Gmail inbox with Javamail, but I can't. I only retrieve archived messages (from 2011!!!) and I don't know why or how to do it.
Here is my code:
public List<DefaultMessage> getLatestNthMessages(Integer numberOfMessages) throws Exception {
URLName url = new URLName("pop3", "pop.gmail.com", 995, "",username, password);
Store store = new POP3SSLStore(pullSession, url);
store.connect();
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
SearchTerm st = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
List<Message> msgs = Arrays.asList(inbox.search(st)).stream()
.sorted((m1, m2) -> m2.getMessageNumber() - m1.getMessageNumber())
.limit(numberOfMessages)
.collect(Collectors.toList());
List<DefaultMessage> listOfMessages = new ArrayList<>();
for (Message message : msgs) {
listOfMessages.add(wrapperToMessage(message));
}
return listOfMessages;
}
pullSession is instantiated as follows:
Properties pullProps = new Properties();
pullProps.put("mail.pop3.host", pullHost);
pullProps.put("mail.pop3.username", username);
pullProps.put("mail.pop3.port", pullPort);
pullProps.put("mail.pop3.socketFactory.port", pullPort);
pullProps.put("mail.pop3.socketFactory.fallback", "false");
pullProps.put("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
pullProps.put("mail.pop3.auth", "true");
pullSession = Session.getInstance(pullProps, null);
pullSession.setDebug(true);
Check your Gmail settings for POP3.
Also, there's lots of things you can improve in your code, although they're not the source of your problem. Start by fixing all the common JavaMail mistakes.
You should not be creating a POP3SSLStore directly. Use the Gmail example code in the JavaMail FAQ.
I want to set LDAP connection to list all users from AD.
I successfully accomplished this with information stored in XML
<ldap:context-source
url="ldap://<url>"
base="dc=example,dc=local"
username="<user>#example.local"
password="<pass>" />
But how I can set this informations from Java, not in XML?
Tried with:
LdapContextSource ctxSrc = new LdapContextSource();
ctxSrc.setUrl("ldap://<url>");
ctxSrc.setBase("dc=example,dc=local");
ctxSrc.setUserDn("<user>#example.local");
ctxSrc.setPassword("<pass>");
LdapTemplate tmpl = new LdapTemplate(ctxSrc);
setLdapTemplate(tmpl);
But when runing
List users = (List<User>) ldapTemplate.search(LdapUtils.emptyLdapName(), "(&(objectCategory=person)(objectClass=user))", new UserAttributesMapper());
I get NullPointerExeption. Runing that without setting up properties from java (i.e. reading from xml) everything works fine
please try this
LdapContextSource ctxSrc = new LdapContextSource();
ctxSrc.setUrl("ldap://<url>");
ctxSrc.setBase("dc=example,dc=local");
ctxSrc.setUserDn("<user>#example.local");
ctxSrc.setPassword("<pass>");
ctxSrc.afterPropertiesSet(); // this method should be called.
LdapTemplate tmpl = new LdapTemplate(ctxSrc);
setLdapTemplate(tmpl);