Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 8 additions & 73 deletions cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
import logging
from warnings import warn
from random import random
import re
import queue
import socket
import sys

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A drive-by fix. I noticed these two imports were unused while working on CASSPYTHON-13 with Brett, figured I'd clean them up next time I was in this code.

import time
from threading import Lock, RLock, Thread, Event
import uuid
Expand Down Expand Up @@ -83,9 +81,6 @@
from cassandra.timestamps import MonotonicTimestampGenerator
from cassandra.util import _resolve_contact_points_to_string_map, Version

from cassandra.datastax.insights.reporter import MonitorReporter
from cassandra.datastax.insights.util import version_supports_insights

from cassandra.datastax.graph import (graph_object_row_factory, GraphOptions, GraphSON1Serializer,
GraphProtocol, GraphSON2Serializer, GraphStatement, SimpleGraphStatement,
graph_graphson2_row_factory, graph_graphson3_row_factory,
Expand Down Expand Up @@ -950,34 +945,6 @@ def default_retry_policy(self, policy):
documentation for :meth:`Session.timestamp_generator`.
"""

monitor_reporting_enabled = True
"""
A boolean indicating if monitor reporting, which sends gathered data to
Insights when running against DSE 6.8 and higher.
"""

monitor_reporting_interval = 30
"""
A boolean indicating if monitor reporting, which sends gathered data to
Insights when running against DSE 6.8 and higher.
"""

client_id = None
"""
A UUID that uniquely identifies this Cluster object to Insights. This will
be generated automatically unless the user provides one.
"""

application_name = ''
"""
A string identifying this application to Insights.
"""

application_version = ''
"""
A string identifying this application's version to Insights
"""

cloud = None
"""
A dict of the cloud configuration. Example::
Expand Down Expand Up @@ -1096,11 +1063,6 @@ def __init__(self,
no_compact=False,
ssl_context=None,
endpoint_factory=None,
application_name=None,
application_version=None,
monitor_reporting_enabled=True,
monitor_reporting_interval=30,
client_id=None,
cloud=None,
column_encryption_policy=None):
"""
Expand Down Expand Up @@ -1159,8 +1121,6 @@ def __init__(self,
raw_contact_points.append(cp if isinstance(cp, tuple) else (cp, port))

self.endpoints_resolved = [cp for cp in self.contact_points if isinstance(cp, EndPoint)]
self._endpoint_map_for_insights = {repr(ep): '{ip}:{port}'.format(ip=ep.address, port=ep.port)
for ep in self.endpoints_resolved}

strs_resolved_map = _resolve_contact_points_to_string_map(raw_contact_points)
self.endpoints_resolved.extend(list(chain(
Expand All @@ -1170,14 +1130,14 @@ def __init__(self,
]
)))

self._endpoint_map_for_insights.update(
{key: ['{ip}:{port}'.format(ip=ip, port=port) for ip, port in value]
for key, value in strs_resolved_map.items() if value is not None}
)

if contact_points and (not self.endpoints_resolved):
# only want to raise here if the user specified CPs but resolution failed
raise UnresolvableContactPoints(self._endpoint_map_for_insights)
endpoint_map = {repr(ep): '{ip}:{port}'.format(ip=ep.address, port=ep.port) for ep in self.endpoints_resolved}
endpoint_map.update(
{key: ['{ip}:{port}'.format(ip=ip, port=port) for ip, port in value]
for key, value in strs_resolved_map.items() if value is not None}
)
raise UnresolvableContactPoints(endpoint_map)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems weird to me that we were re-using an Insights map in the exception that's thrown here.. but apparently we were. Moved the logic into this block (so that it's only executed if an exception actually occurs) and moved everything out of class state.


self.compression = compression

Expand Down Expand Up @@ -1301,8 +1261,6 @@ def __init__(self,
self.connect_timeout = connect_timeout
self.prepare_on_all_hosts = prepare_on_all_hosts
self.reprepare_on_up = reprepare_on_up
self.monitor_reporting_enabled = monitor_reporting_enabled
self.monitor_reporting_interval = monitor_reporting_interval

self._listeners = set()
self._listener_lock = Lock()
Expand Down Expand Up @@ -1352,13 +1310,6 @@ def __init__(self,
self.status_event_refresh_window,
schema_metadata_enabled, token_metadata_enabled)

if client_id is None:
self.client_id = uuid.uuid4()
if application_name is not None:
self.application_name = application_name
if application_version is not None:
self.application_version = application_version

def register_user_type(self, keyspace, user_type, klass):
"""
Registers a class to use to represent a particular user-defined type.
Expand Down Expand Up @@ -2473,8 +2424,7 @@ def default_serial_consistency_level(self, cl):

session_id = None
"""
A UUID that uniquely identifies this Session to Insights. This will be
generated automatically.
A UUID that uniquely identifies this Session. This will be generated automatically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had originally planned on removing this entirely but this ID is also used in column-level encryption (CLE)

"""

_lock = None
Expand Down Expand Up @@ -2527,22 +2477,7 @@ def __init__(self, cluster, hosts, keyspace=None):
except AttributeError:
log.info("Unable to set column encryption policy for session")

if self.cluster.monitor_reporting_enabled:
cc_host = self.cluster.get_control_connection_host()
valid_insights_version = (cc_host and version_supports_insights(cc_host.dse_version))
if valid_insights_version:
self._monitor_reporter = MonitorReporter(
interval_sec=self.cluster.monitor_reporting_interval,
session=self,
)
else:
if cc_host:
log.debug('Not starting MonitorReporter thread for Insights; '
'not supported by server version {v} on '
'ControlConnection host {c}'.format(v=cc_host.release_version, c=cc_host))

log.debug('Started Session with client_id {} and session_id {}'.format(self.cluster.client_id,
self.session_id))
log.debug('Started Session with session_id {}'.format(self.session_id))

def execute(self, query, parameters=None, timeout=_NOT_SET, trace=False,
custom_payload=None, execution_profile=EXEC_PROFILE_DEFAULT,
Expand Down
15 changes: 0 additions & 15 deletions cassandra/datastax/insights/__init__.py

This file was deleted.

124 changes: 0 additions & 124 deletions cassandra/datastax/insights/registry.py

This file was deleted.

Loading