Skip to content

Commit

Permalink
Remove Windows-specific classes and related code
Browse files Browse the repository at this point in the history
patch by Stefan Miklosovic; reviewed by Joshua McKenzie, Bowen Song, Berenguer Blasi for CASSANDRA-16956
  • Loading branch information
smiklosovic committed Feb 5, 2022
1 parent 28eea6e commit da47849
Show file tree
Hide file tree
Showing 53 changed files with 80 additions and 953 deletions.
6 changes: 0 additions & 6 deletions .build/build-resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@
<url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-freebsd-6.so"/>
<url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
<url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
<url url="${lib.download.base.url}/lib/sigar-bin/sigar-amd64-winnt.dll"/>
<url url="${lib.download.base.url}/lib/sigar-bin/sigar-x86-winnt.dll"/>
<url url="${lib.download.base.url}/lib/sigar-bin/sigar-x86-winnt.lib"/>
</get>

<copy todir="${build.lib}" quiet="true">
Expand Down Expand Up @@ -254,9 +251,6 @@
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-freebsd-6.so"/>
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/sigar-amd64-winnt.dll"/>
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/sigar-x86-winnt.dll"/>
<file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/sigar-x86-winnt.lib"/>
</copy>
</target>
</project>
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
4.1
* Remove support for Windows (CASSANDRA-16956)
* Runtime-configurable YAML option to prohibit USE statements (CASSANDRA-17318)
* When streaming sees a ClosedChannelException this triggers the disk failure policy (CASSANDRA-17116)
* Add a virtual table for exposing prepared statements metrics (CASSANDRA-17224)
Expand Down
8 changes: 0 additions & 8 deletions bin/cassandra
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ if [ -z "$CASSANDRA_LOG_DIR" ]; then
CASSANDRA_LOG_DIR=$CASSANDRA_HOME/logs
fi

# Special-case path variables.
case "`uname`" in
CYGWIN*|MINGW*)
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
CASSANDRA_CONF=`cygpath -p -w "$CASSANDRA_CONF"`
;;
esac

# Cassandra uses an installed jemalloc via LD_PRELOAD / DYLD_INSERT_LIBRARIES by default to improve off-heap
# memory allocation performance. The following code searches for an installed libjemalloc.dylib/.so/.1.so using
# Linux and OS-X specific approaches.
Expand Down
48 changes: 12 additions & 36 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import platform
import re
import stat
import subprocess
import sys
import traceback
import warnings
Expand All @@ -44,7 +45,6 @@
sys.exit("\nCQL Shell does not run on Jython\n")

UTF8 = 'utf-8'
CP65001 = 'cp65001' # Win utf-8 variant

description = "CQL Shell for Apache Cassandra"
version = "6.0.0"
Expand Down Expand Up @@ -92,14 +92,8 @@
# use bundled lib for python-cql if available. if there
# is a ../lib dir, use bundled libs there preferentially.
ZIPLIB_DIRS = [os.path.join(CASSANDRA_PATH, 'lib')]
myplatform = platform.system()
is_win = myplatform == 'Windows'

# Workaround for supporting CP65001 encoding on python < 3.3 (https://bugs.python.org/issue13216)
if is_win and sys.version_info < (3, 3):
codecs.register(lambda name: codecs.lookup(UTF8) if name == CP65001 else None)

if myplatform == 'Linux':
if platform.system() == 'Linux':
ZIPLIB_DIRS.append('/usr/share/cassandra/lib')

if os.environ.get('CQLSH_NO_BUNDLED', ''):
Expand Down Expand Up @@ -211,7 +205,7 @@ def find_zip(libprefix):
parser.add_option('--coverage', action='store_true',
help='Collect coverage data')
parser.add_option("--encoding", help="Specify a non-default encoding for output."
" (Default: %s)" % (UTF8,))
+ " (Default: %s)" % (UTF8,))
parser.add_option("--cqlshrc", help="Specify an alternative cqlshrc file location.")
parser.add_option("--credentials", help="Specify an alternative credentials file location.")
parser.add_option('--cqlversion', default=None,
Expand Down Expand Up @@ -261,9 +255,9 @@ def find_zip(libprefix):
if os.path.exists(OLD_CONFIG_FILE):
if os.path.exists(CONFIG_FILE):
print('\nWarning: cqlshrc config files were found at both the old location ({0})'
' and the new location ({1}), the old config file will not be migrated to the new'
' location, and the new location will be used for now. You should manually'
' consolidate the config files at the new location and remove the old file.'
+ ' and the new location ({1}), the old config file will not be migrated to the new'
+ ' location, and the new location will be used for now. You should manually'
+ ' consolidate the config files at the new location and remove the old file.'
.format(OLD_CONFIG_FILE, CONFIG_FILE))
else:
os.rename(OLD_CONFIG_FILE, CONFIG_FILE)
Expand Down Expand Up @@ -508,7 +502,6 @@ def __init__(self, hostname, port, color=False,

self.tty = tty
self.encoding = encoding
self.check_windows_encoding()

self.output_codec = codecs.lookup(encoding)

Expand Down Expand Up @@ -543,15 +536,7 @@ def batch_mode(self):
@property
def is_using_utf8(self):
# utf8 encodings from https://docs.python.org/{2,3}/library/codecs.html
return self.encoding.replace('-', '_').lower() in ['utf', 'utf_8', 'u8', 'utf8', CP65001]

def check_windows_encoding(self):
if is_win and os.name == 'nt' and self.tty and \
self.is_using_utf8 and sys.stdout.encoding != CP65001:
self.printerr("\nWARNING: console codepage must be set to cp65001 "
"to support {} encoding on Windows platforms.\n"
"If you experience encoding problems, change your console"
" codepage with 'chcp 65001' before starting cqlsh.\n".format(self.encoding))
return self.encoding.replace('-', '_').lower() in ['utf', 'utf_8', 'u8', 'utf8']

def set_expanded_cql_version(self, ver):
ver, vertuple = full_cql_version(ver)
Expand Down Expand Up @@ -817,8 +802,6 @@ def prepare_loop(self):
try:
import readline
except ImportError:
if is_win:
print("WARNING: pyreadline dependency missing. Install to enable tab completion.")
pass
else:
old_completer = readline.get_completer()
Expand Down Expand Up @@ -1886,8 +1869,7 @@ def do_clear(self, parsed):
Clears the console.
"""
import subprocess
subprocess.call(['clear', 'cls'][is_win], shell=True)
subprocess.call('clear', shell=True)
do_cls = do_clear

def do_debug(self, parsed):
Expand Down Expand Up @@ -2098,7 +2080,6 @@ def should_use_color():
if os.environ.get('TERM', '') in ('dumb', ''):
return False
try:
import subprocess
p = subprocess.Popen(['tput', 'colors'], stdout=subprocess.PIPE)
stdout, _ = p.communicate()
if int(stdout.strip()) < 8:
Expand All @@ -2111,11 +2092,6 @@ def should_use_color():


def is_file_secure(filename):
if is_win:
# We simply cannot tell whether the file is seucre on Windows,
# because os.stat().st_uid is always 0 and os.stat().st_mode is meaningless
return True

try:
st = os.stat(filename)
except OSError as e:
Expand Down Expand Up @@ -2359,9 +2335,9 @@ def main(options, hostname, port):
# does contain a TZ part) was specified
if options.time_format != DEFAULT_TIMESTAMP_FORMAT:
sys.stderr.write("Warning: custom timestamp format specified in cqlshrc, "
"but local timezone could not be detected.\n"
"Either install Python 'tzlocal' module for auto-detection "
"or specify client timezone in your cqlshrc.\n\n")
+ "but local timezone could not be detected.\n"
+ "Either install Python 'tzlocal' module for auto-detection "
+ "or specify client timezone in your cqlshrc.\n\n")

try:
shell = Shell(hostname,
Expand Down Expand Up @@ -2414,7 +2390,7 @@ def handle_sighup():


# always call this regardless of module name: when a sub-process is spawned
# on Windows then the module name is not __main__, see CASSANDRA-9304
# on Windows then the module name is not __main__, see CASSANDRA-9304 (Windows support was dropped in CASSANDRA-16956)
insert_driver_hooks()

if __name__ == '__main__':
Expand Down
8 changes: 0 additions & 8 deletions bin/debug-cql
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
. "$CASSANDRA_CONF/cassandra-env.sh"
fi

# Special-case path variables.
case "`uname`" in
CYGWIN*|MINGW*)
CLASSPATH="`cygpath -p -w "$CLASSPATH"`"
CASSANDRA_CONF="`cygpath -p -w "$CASSANDRA_CONF"`"
;;
esac

class="org.apache.cassandra.transport.Client"
cassandra_parms="-Dlogback.configurationFile=logback-tools.xml"
"$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH" "$class" $@
Expand Down
8 changes: 0 additions & 8 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1319,14 +1319,6 @@ enable_user_defined_functions: false
# This option has no effect, if enable_user_defined_functions is false.
enable_scripted_user_defined_functions: false

# The default Windows kernel timer and scheduling resolution is 15.6ms for power conservation.
# Lowering this value on Windows can provide much tighter latency and better throughput, however
# some virtualized environments may see a negative performance impact from changing this setting
# below their system default. The sysinternals 'clockres' tool can confirm your system's default
# setting.
windows_timer_interval: 1


# Enables encrypting data at-rest (on disk). Different key providers can be plugged in, but the default reads from
# a JCE-style keystore. A single keystore can hold multiple keys, but the one referenced by
# the "key_alias" is the only key that will be used for encrypt opertaions; previously used keys
Expand Down
6 changes: 3 additions & 3 deletions doc/modules/cassandra/pages/operating/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ the first based on standard JMX security and the second which integrates
more closely with Cassandra's own auth subsystem.

The default settings for Cassandra make JMX accessible only from
localhost. To enable remote JMX connections, edit `cassandra-env.sh` (or
`cassandra-env.ps1` on Windows) to change the `LOCAL_JMX` setting to
localhost. To enable remote JMX connections, edit `cassandra-env.sh`
to change the `LOCAL_JMX` setting to
`no`. Under the standard configuration, when remote JMX connections are
enabled, `standard JMX authentication <standard-jmx-auth>` is also
switched on.
Expand Down Expand Up @@ -490,7 +490,7 @@ See also: xref:cql/security.adoc#permissions[`Permissions`].

JMX SSL configuration is controlled by a number of system properties,
some of which are optional. To turn on SSL, edit the relevant lines in
`cassandra-env.sh` (or `cassandra-env.ps1` on Windows) to uncomment and
`cassandra-env.sh` to uncomment and
set the values of these properties as required:

`com.sun.management.jmxremote.ssl`::
Expand Down
12 changes: 6 additions & 6 deletions pylib/cqlshlib/copyutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def __init__(self, fname, options):
self.max_rows = options.copy['maxrows']
self.skip_rows = options.copy['skiprows']
self.fname = fname
self.sources = None # must be created later due to pickle problems on Windows
self.sources = None # might be initialised directly here? (see CASSANDRA-17350)
self.num_sources = 0
self.current_source = None
self.num_read = 0
Expand Down Expand Up @@ -1299,9 +1299,9 @@ def __init__(self, inpipe, outpipe, worker_pipes, fname, options):
self.inpipe = inpipe
self.outpipe = outpipe
self.worker_pipes = worker_pipes
self.inmsg = None # must be created after forking on Windows
self.outmsg = None # must be created after forking on Windows
self.worker_channels = None # must be created after forking on Windows
self.inmsg = None # might be initialised directly here? (see CASSANDRA-17350)
self.outmsg = None # might be initialised directly here? (see CASSANDRA-17350)
self.worker_channels = None # might be initialised directly here? (see CASSANDRA-17350)
self.reader = FilesReader(fname, options) if fname else PipeReader(inpipe, options)
self.send_meter = RateMeter(log_fcn=None, update_interval=1)
self.ingest_rate = options.copy['ingestrate']
Expand Down Expand Up @@ -1405,8 +1405,8 @@ def __init__(self, params, target):
super(ChildProcess, self).__init__(target=target)
self.inpipe = params['inpipe']
self.outpipe = params['outpipe']
self.inmsg = None # must be initialized after fork on Windows
self.outmsg = None # must be initialized after fork on Windows
self.inmsg = None # might be initialised directly here? (see CASSANDRA-17350)
self.outmsg = None # might be initialised directly here? (see CASSANDRA-17350)
self.ks = params['ks']
self.table = params['table']
self.local_dc = params['local_dc']
Expand Down
2 changes: 0 additions & 2 deletions pylib/cqlshlib/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
from .displaying import colorme, get_str, FormattedValue, DEFAULT_VALUE_COLORS, NO_COLOR_MAP
from .util import UTC

is_win = platform.system() == 'Windows'

unicode_controlchars_re = re.compile(r'[\x00-\x31\x7f-\xa0]')
controlchars_re = re.compile(r'[\x00-\x31\x7f-\xff]')

Expand Down
Loading

0 comments on commit da47849

Please sign in to comment.