Skip to content

Commit 242b4e8

Browse files
author
Mark
committed
Merge remote-tracking branch 'origin/4.1'
2 parents b8903a8 + 135c323 commit 242b4e8

File tree

10 files changed

+280
-3
lines changed

10 files changed

+280
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v4.1.0 (2016-10-xx)
2+
---------------------------
3+
* changed VelocyStream communication (send protocol header)
4+
15
v4.0.0 (2016-10-17)
26
---------------------------
37
* replaced API

docs/setup.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ Example for arangodb.properties:
4343
arangodb.user=root
4444
arangodb.password=
4545

46+
```
47+
48+
## SSL
49+
50+
To use SSL, you have to set the configuration `useSsl` to `true` and set a `SSLContext`. (see [example code](../src/test/java/com/arangodb/example/ssl/SslExample.java))
51+
52+
``` Java
53+
54+
ArangoDB arangoDB = new ArangoDB.Builder().useSsl(true).sslContext(sc).build();
55+
4656
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.arangodb</groupId>
66
<artifactId>arangodb-java-driver</artifactId>
7-
<version>4.0.0</version>
7+
<version>4.1.0-SNAPSHOT</version>
88
<inceptionYear>2016</inceptionYear>
99
<packaging>jar</packaging>
1010

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.arangodb.entity.ArangoDBVersion;
3131
import com.arangodb.entity.LogEntity;
32+
import com.arangodb.entity.LogLevelEntity;
3233
import com.arangodb.entity.UserEntity;
3334
import com.arangodb.internal.ArangoDBConstants;
3435
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
@@ -415,4 +416,25 @@ public LogEntity getLogs(final LogOptions options) throws ArangoDBException {
415416
return executor.execute(getLogsRequest(options), LogEntity.class);
416417
}
417418

419+
/**
420+
* Returns the server's current loglevel settings.
421+
*
422+
* @return the server's current loglevel settings
423+
* @throws ArangoDBException
424+
*/
425+
public LogLevelEntity getLogLevel() throws ArangoDBException {
426+
return executor.execute(getLogLevelRequest(), LogLevelEntity.class);
427+
}
428+
429+
/**
430+
* Modifies and returns the server's current loglevel settings.
431+
*
432+
* @param entity
433+
* loglevel settings
434+
* @return the server's current loglevel settings
435+
* @throws ArangoDBException
436+
*/
437+
public LogLevelEntity setLogLevel(final LogLevelEntity entity) throws ArangoDBException {
438+
return executor.execute(setLogLevelRequest(entity), LogLevelEntity.class);
439+
}
418440
}
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* @author Mark - mark at arangodb.com
25+
*
26+
*/
27+
public class LogLevelEntity {
28+
29+
public enum LogLevel {
30+
FATAL, ERROR, WARNING, INFO, DEBUG, DEFAULT;
31+
}
32+
33+
private LogLevel agency;
34+
private LogLevel agencycomm;
35+
private LogLevel cluster;
36+
private LogLevel collector;
37+
private LogLevel communication;
38+
private LogLevel compactor;
39+
private LogLevel config;
40+
private LogLevel datafiles;
41+
private LogLevel graphs;
42+
private LogLevel heartbeat;
43+
private LogLevel mmap;
44+
private LogLevel performance;
45+
private LogLevel queries;
46+
private LogLevel replication;
47+
private LogLevel requests;
48+
private LogLevel startup;
49+
private LogLevel threads;
50+
private LogLevel v8;
51+
52+
public LogLevelEntity() {
53+
super();
54+
}
55+
56+
public LogLevel getAgency() {
57+
return agency;
58+
}
59+
60+
public void setAgency(final LogLevel agency) {
61+
this.agency = agency;
62+
}
63+
64+
public LogLevel getAgencycomm() {
65+
return agencycomm;
66+
}
67+
68+
public void setAgencycomm(final LogLevel agencycomm) {
69+
this.agencycomm = agencycomm;
70+
}
71+
72+
public LogLevel getCluster() {
73+
return cluster;
74+
}
75+
76+
public void setCluster(final LogLevel cluster) {
77+
this.cluster = cluster;
78+
}
79+
80+
public LogLevel getCollector() {
81+
return collector;
82+
}
83+
84+
public void setCollector(final LogLevel collector) {
85+
this.collector = collector;
86+
}
87+
88+
public LogLevel getCommunication() {
89+
return communication;
90+
}
91+
92+
public void setCommunication(final LogLevel communication) {
93+
this.communication = communication;
94+
}
95+
96+
public LogLevel getCompactor() {
97+
return compactor;
98+
}
99+
100+
public void setCompactor(final LogLevel compactor) {
101+
this.compactor = compactor;
102+
}
103+
104+
public LogLevel getConfig() {
105+
return config;
106+
}
107+
108+
public void setConfig(final LogLevel config) {
109+
this.config = config;
110+
}
111+
112+
public LogLevel getDatafiles() {
113+
return datafiles;
114+
}
115+
116+
public void setDatafiles(final LogLevel datafiles) {
117+
this.datafiles = datafiles;
118+
}
119+
120+
public LogLevel getGraphs() {
121+
return graphs;
122+
}
123+
124+
public void setGraphs(final LogLevel graphs) {
125+
this.graphs = graphs;
126+
}
127+
128+
public LogLevel getHeartbeat() {
129+
return heartbeat;
130+
}
131+
132+
public void setHeartbeat(final LogLevel heartbeat) {
133+
this.heartbeat = heartbeat;
134+
}
135+
136+
public LogLevel getMmap() {
137+
return mmap;
138+
}
139+
140+
public void setMmap(final LogLevel mmap) {
141+
this.mmap = mmap;
142+
}
143+
144+
public LogLevel getPerformance() {
145+
return performance;
146+
}
147+
148+
public void setPerformance(final LogLevel performance) {
149+
this.performance = performance;
150+
}
151+
152+
public LogLevel getQueries() {
153+
return queries;
154+
}
155+
156+
public void setQueries(final LogLevel queries) {
157+
this.queries = queries;
158+
}
159+
160+
public LogLevel getReplication() {
161+
return replication;
162+
}
163+
164+
public void setReplication(final LogLevel replication) {
165+
this.replication = replication;
166+
}
167+
168+
public LogLevel getRequests() {
169+
return requests;
170+
}
171+
172+
public void setRequests(final LogLevel requests) {
173+
this.requests = requests;
174+
}
175+
176+
public LogLevel getStartup() {
177+
return startup;
178+
}
179+
180+
public void setStartup(final LogLevel startup) {
181+
this.startup = startup;
182+
}
183+
184+
public LogLevel getThreads() {
185+
return threads;
186+
}
187+
188+
public void setThreads(final LogLevel threads) {
189+
this.threads = threads;
190+
}
191+
192+
public LogLevel getV8() {
193+
return v8;
194+
}
195+
196+
public void setV8(final LogLevel v8) {
197+
this.v8 = v8;
198+
}
199+
200+
}

src/main/java/com/arangodb/internal/ArangoDBConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class ArangoDBConstants {
5656
public static final String PATH_API_QUERY_SLOW = "/_api/query/slow";
5757
public static final String PATH_API_TRAVERSAL = "/_api/traversal";
5858
public static final String PATH_API_ADMIN_LOG = "/_admin/log";
59+
public static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level";
5960
public static final String PATH_API_ADMIN_ROUTING_RELOAD = "/_admin/routing/reload";
6061

6162
public static final String ENCRYPTION_PLAIN = "plain";

src/main/java/com/arangodb/internal/InternalArangoDB.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.util.Collection;
2424

25+
import com.arangodb.entity.LogLevelEntity;
2526
import com.arangodb.entity.UserEntity;
2627
import com.arangodb.internal.ArangoExecutor.ResponseDeserializer;
2728
import com.arangodb.internal.velocystream.Connection;
@@ -150,4 +151,13 @@ protected Request getLogsRequest(final LogOptions options) {
150151
.putQueryParam(LogOptions.PROPERTY_SEARCH, params.getSearch())
151152
.putQueryParam(LogOptions.PROPERTY_SORT, params.getSort());
152153
}
154+
155+
protected Request getLogLevelRequest() {
156+
return new Request(ArangoDBConstants.SYSTEM, RequestType.GET, ArangoDBConstants.PATH_API_ADMIN_LOG_LEVEL);
157+
}
158+
159+
protected Request setLogLevelRequest(final LogLevelEntity entity) {
160+
return new Request(ArangoDBConstants.SYSTEM, RequestType.PUT, ArangoDBConstants.PATH_API_ADMIN_LOG_LEVEL)
161+
.setBody(executor.serialize(entity));
162+
}
153163
}

src/main/java/com/arangodb/internal/velocystream/Connection.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
public abstract class Connection {
5050

5151
private static final Logger LOGGER = LoggerFactory.getLogger(Connection.class);
52+
private static final byte[] PROTOCOL_HEADER = "VST/1.0\r\n\r\n".getBytes();
5253

5354
private final String host;
5455
private final Integer port;
@@ -109,6 +110,7 @@ public synchronized void open() throws IOException {
109110
}
110111
((SSLSocket) socket).startHandshake();
111112
}
113+
sendProtocolHeader();
112114
}
113115

114116
public synchronized void close() {
@@ -124,6 +126,11 @@ public synchronized void close() {
124126
}
125127
}
126128

129+
private void sendProtocolHeader() throws IOException {
130+
outputStream.write(PROTOCOL_HEADER);
131+
outputStream.flush();
132+
}
133+
127134
protected synchronized void writeIntern(final Message message, final Collection<Chunk> chunks) {
128135
for (final Chunk chunk : chunks) {
129136
try {

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.arangodb.entity.ArangoDBVersion;
4242
import com.arangodb.entity.LogEntity;
4343
import com.arangodb.entity.LogLevel;
44+
import com.arangodb.entity.LogLevelEntity;
4445
import com.arangodb.entity.UserEntity;
4546
import com.arangodb.model.LogOptions;
4647
import com.arangodb.model.LogOptions.SortOrder;
@@ -361,4 +362,26 @@ public void getLogsSortDesc() {
361362
}
362363
}
363364

365+
@Test
366+
public void getLogLevel() {
367+
final ArangoDB arangoDB = new ArangoDB.Builder().build();
368+
final LogLevelEntity logLevel = arangoDB.getLogLevel();
369+
assertThat(logLevel, is(notNullValue()));
370+
assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.INFO));
371+
}
372+
373+
@Test
374+
public void setLogLevel() {
375+
final ArangoDB arangoDB = new ArangoDB.Builder().build();
376+
final LogLevelEntity entity = new LogLevelEntity();
377+
try {
378+
entity.setAgency(LogLevelEntity.LogLevel.ERROR);
379+
final LogLevelEntity logLevel = arangoDB.setLogLevel(entity);
380+
assertThat(logLevel, is(notNullValue()));
381+
assertThat(logLevel.getAgency(), is(LogLevelEntity.LogLevel.ERROR));
382+
} finally {
383+
entity.setAgency(LogLevelEntity.LogLevel.INFO);
384+
arangoDB.setLogLevel(entity);
385+
}
386+
}
364387
}

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ public void explainQuery() {
513513
assertThat(plan.getCollections().size(), is(1));
514514
assertThat(plan.getCollections().iterator().next().getName(), is("_apps"));
515515
assertThat(plan.getCollections().iterator().next().getType(), is("read"));
516-
assertThat(plan.getEstimatedCost(), is(5));
517-
assertThat(plan.getEstimatedNrItems(), is(2));
516+
assertThat(plan.getEstimatedCost(), greaterThan(0));
517+
assertThat(plan.getEstimatedNrItems(), greaterThan(0));
518518
assertThat(plan.getVariables().size(), is(1));
519519
assertThat(plan.getVariables().iterator().next().getName(), is("i"));
520520
assertThat(plan.getNodes().size(), is(3));

0 commit comments

Comments
 (0)