Skip to content

Commit e9ba529

Browse files
authored
Merge pull request #251 from smkniazi/HOPS-1625
[HOPS-1625] RonDB 21.04.0
2 parents 1784a60 + cbde54d commit e9ba529

File tree

6 files changed

+41
-15
lines changed

6 files changed

+41
-15
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
<dependency>
2727
<groupId>com.mysql.ndb</groupId>
28-
<artifactId>clusterj-hops-fix</artifactId>
29-
<version>8.0.21</version>
28+
<artifactId>clusterj-rondb</artifactId>
29+
<version>21.04.0</version>
3030
</dependency>
3131

3232
<dependency>

src/main/java/io/hops/metadata/ndb/ClusterjConnector.java

+13
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,19 @@ private boolean format(boolean transactional,
386386
Class<? extends EntityDataAccess>... das) throws StorageException {
387387

388388
final int RETRIES = 5; // in test
389+
390+
// we need to clear the cache objects
391+
if(!transactional) {
392+
// This calls the SQL truncate command which changes the schema ID.
393+
// After calling truncate we reload the schema to avoid schema ID change
394+
// exceptions. However, reloading the schema invalidates the
395+
// objects in the DTO cache in the ClusterJ causing NPEs.
396+
// Wipe the cache before we call truncate and reload the schema
397+
398+
// we clear the cache for all open sessions
399+
dbSessionProvider.clearCache();
400+
}
401+
389402
for (int i = 0; i < RETRIES; i++) {
390403
try {
391404
for (Class e : das) {

src/main/java/io/hops/metadata/ndb/DBSessionProvider.java

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.commons.logging.Log;
3131
import org.apache.commons.logging.LogFactory;
3232

33+
import java.util.Iterator;
3334
import java.util.NoSuchElementException;
3435
import java.util.Properties;
3536
import java.util.Random;
@@ -212,4 +213,12 @@ public void run() {
212213
}
213214
}
214215
}
216+
217+
public void clearCache() throws StorageException {
218+
Iterator<DBSession> itr = sessionPool.iterator();
219+
while(itr.hasNext()){
220+
DBSession session = itr.next();
221+
session.getSession().dropInstanceCache();
222+
}
223+
}
215224
}

src/main/java/io/hops/metadata/ndb/dalimpl/hdfs/LeaseCreationLocksClusterj.java

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public void createLockRows(int count) throws StorageException {
6464
dto.setID(i);
6565
session.savePersistent(dto);
6666
session.release(dto);
67-
LOG.debug("Added lease creation lock row with ID: "+i);
6867
}
6968
}
7069
}

src/main/java/io/hops/metadata/ndb/wrapper/HopsSession.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,19 @@ public String unloadSchema(Class<?> aClass) throws StorageException {
262262
throw HopsExceptionHelper.wrap(e);
263263
}
264264
}
265-
265+
266+
public void dropInstanceCache() throws StorageException {
267+
try {
268+
session.dropInstanceCache();
269+
} catch (ClusterJException e) {
270+
throw HopsExceptionHelper.wrap(e);
271+
}
272+
}
273+
266274
public <T> void release(T t) throws StorageException {
267275
try {
268276
if(t!=null){
269-
session.release(t);
277+
session.releaseCache(t, t.getClass());
270278
}
271279
} catch (ClusterJException e) {
272280
throw HopsExceptionHelper.wrap(e);
@@ -277,7 +285,7 @@ public <T> void release(Collection<T> t) throws StorageException {
277285
try {
278286
if(t!=null){
279287
for(T dto : t) {
280-
session.release(dto);
288+
session.releaseCache(dto, dto.getClass());
281289
}
282290
}
283291
} catch (ClusterJException e) {

src/main/resources/ndb-config.properties.template

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
#
2-
# Do not add spaces in the file. it is also used by some deployment scripts that fail if there are redundant spaces
3-
#
4-
com.mysql.clusterj.connectstring=cloud1.sics.se
5-
com.mysql.clusterj.database=hop_bram_vm
1+
com.mysql.clusterj.connectstring=localhost
2+
com.mysql.clusterj.database=hops_db
63
com.mysql.clusterj.connection.pool.size=1
74
com.mysql.clusterj.max.transactions=1024
8-
#com.mysql.clusterj.connection.pool.nodeids=
5+
com.mysql.clusterj.max.cached.instances=1024
96

107
io.hops.metadata.ndb.mysqlserver.data_source_class_name = com.mysql.cj.jdbc.MysqlDataSource
118

12-
io.hops.metadata.ndb.mysqlserver.host=
9+
io.hops.metadata.ndb.mysqlserver.host=localhost
1310
io.hops.metadata.ndb.mysqlserver.port=3306
14-
io.hops.metadata.ndb.mysqlserver.username=
15-
io.hops.metadata.ndb.mysqlserver.password=
11+
io.hops.metadata.ndb.mysqlserver.username=username
12+
io.hops.metadata.ndb.mysqlserver.password=password
1613
io.hops.metadata.ndb.mysqlserver.connection_pool_size=1
1714

1815
#size of the session pool. should be altreat as big as the number of active RPC handling Threads in the system

0 commit comments

Comments
 (0)