• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Commonjava / indy-tracking-service / 44786446415

20 Nov 2026 05:46PM UTC coverage: 37.562% (-29.5%) from 67.036%
44786446415

push

github

rnc
Bump org.commonjava.atlas:atlas-relationships-api from 1.2.2 to 1.2.3

Bumps [org.commonjava.atlas:atlas-relationships-api](https://github.com/Commonjava/atlas) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/Commonjava/atlas/releases)
- [Commits](https://github.com/Commonjava/atlas/compare/atlas-parent-1.2.2...atlas-parent-1.2.3)

---
updated-dependencies:
- dependency-name: org.commonjava.atlas:atlas-relationships-api
  dependency-version: 1.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

678 of 1805 relevant lines covered (37.56%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.31
/src/main/java/org/commonjava/indy/service/tracking/data/cassandra/CassandraClient.java
1
/**
2
 * Copyright (C) 2022-2023 Red Hat, Inc. (https://github.com/Commonjava/indy-tracking-service)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *         http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package org.commonjava.indy.service.tracking.data.cassandra;
17

18
import com.datastax.driver.core.Cluster;
19
import com.datastax.driver.core.Session;
20
import com.datastax.driver.core.SocketOptions;
21
import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
22
import jakarta.annotation.PostConstruct;
23
import jakarta.enterprise.context.ApplicationScoped;
24
import jakarta.inject.Inject;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

28
import java.util.Map;
29
import java.util.concurrent.ConcurrentHashMap;
30

31
import static org.apache.commons.lang3.StringUtils.isNotBlank;
32

33
@ApplicationScoped
34
public class CassandraClient
35
{
36
    private final Logger logger = LoggerFactory.getLogger( getClass() );
2 ✔
37

38
    final private Map<String, Session> sessions = new ConcurrentHashMap<>();
2 ✔
39

40
    @Inject
41
    CassandraConfiguration config;
42

43
    private String host;
44

45
    private int port;
46

47
    private String username;
48

49
    private Cluster cluster;
50

51
    public CassandraClient()
52
    {
2 ✔
53
    }
2 ✔
54

55
    public CassandraClient( CassandraConfiguration config )
56
    {
×
57
        this.config = config;
×
58
        init();
×
59
    }
×
60

61
    @PostConstruct
62
    public void init()
63
    {
64
        if ( !config.isEnabled() )
2 ✔
65
        {
66
            logger.info( "Cassandra client not enabled" );
×
67
            return;
×
68
        }
69

70
        host = config.getCassandraHost();
2 ✔
71
        port = config.getCassandraPort();
2 ✔
72
        SocketOptions socketOptions = new SocketOptions();
2 ✔
73
        socketOptions.setConnectTimeoutMillis( config.getConnectTimeoutMillis() );
2 ✔
74
        socketOptions.setReadTimeoutMillis( config.getReadTimeoutMillis() );
2 ✔
75
        Cluster.Builder builder = Cluster.builder()
2 ✔
76
                                         .withoutJMXReporting()
2 ✔
77
                                         .withReconnectionPolicy(
2 ✔
78
                                                 new ConstantReconnectionPolicy( config.getConstantDelayMs() ) )
2 ✔
79
                                         .withRetryPolicy( new ConfigurableRetryPolicy( config.getReadRetries(),
2 ✔
80
                                                                                        config.getWriteRetries() ) )
2 ✔
81
                                         .addContactPoint( host )
2 ✔
82
                                         .withPort( port )
2 ✔
83
                                         .withSocketOptions( socketOptions );
2 ✔
84
        username = config.getCassandraUser();
2 ✔
85
        String password = config.getCassandraPass();
2 ✔
86
        if ( isNotBlank( username ) && isNotBlank( password ) )
2 ✔
87
        {
88
            logger.info( "Build with credentials, user: {}, pass: ****", username );
2 ✔
89
            builder.withCredentials( username, password );
2 ✔
90
        }
91
        cluster = builder.build();
2 ✔
92
    }
2 ✔
93

94
    public Session getSession( String keyspace )
95
    {
96
        if ( !config.isEnabled() )
2 ✔
97
        {
98
            logger.info( "Cassandra client not enabled" );
×
99
            return null;
×
100
        }
101

102
        return sessions.computeIfAbsent( keyspace, key -> {
2 ✔
103
            logger.info( "Connect to Cassandra, host: {}, port: {}, user: {}, keyspace: {}", host, port, username,
2 ✔
104
                         key );
105
            try
106
            {
107
                return cluster.connect();
×
108
            }
109
            catch ( Exception e )
2 ✔
110
            {
111
                logger.error( "Connecting to Cassandra failed", e );
2 ✔
112
            }
113
            return null;
2 ✔
114
        } );
115
    }
116

117
    public void close()
118
    {
119
        if ( cluster != null )
×
120
        {
121
            logger.info( "Close cassandra client" );
×
122
            sessions.forEach( ( key, value ) -> value.close() );
×
123
            sessions.clear();
×
124
            cluster.close();
×
125
            cluster = null;
×
126
        }
127
    }
×
128

129
    public Map<String, Session> getSessions()
130
    {
131
        return sessions;
×
132
    }
133
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc