Skip to content
Permalink
Browse files

8250557: Rename vmTestbase/nsk shared timeout handler package to Term…

…inator.java

Rename the class and fix the tests that use it.

Reviewed-by: dcubed
  • Loading branch information
Harold Seigel committed Jul 24, 2020
1 parent 4b076cb commit 9b73fb125d710815187860ecea20fc1e77588a3e
@@ -1,4 +1,4 @@
Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ Short description of files:
text processing:
Grep.java, Paragrep.java
timeouts handling:
Harakiri.java, TimeoutHandler.java
Terminator.java, TimeoutHandler.java
tree structures support:
Denotation.java, TreeNodesDenotation.java
RAS mode support:
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,32 +24,32 @@
package nsk.share;

/**
* Harakiri is used to terminate a stress test with PASS exit status
* Terminator is used to terminate a stress test with PASS exit status
* before the test is terminated as timed out (and so failed).
*
* <p>Harakiri class holds a thread which sleeps for the given amount
* <p>Terminator class holds a thread which sleeps for the given amount
* of time, and then wakes up and executes <tt>System.exit()</tt>
* with the given exit status. That thread is daemon, so it doesn't
* prevent application from exiting once all its threads finish
* before it's time for harakiri. Appointing harakiri in zero
* before it's time for termination. Appointing terminator in zero
* delay implies immediate <tt>exit()</tt>.
*
* <p>There is a limitation: you may appoint no more than one harakiri
* <p>There is a limitation: you may appoint no more than one terminator
* per application.
*/
public class Harakiri {
public class Terminator {
/**
* Use specific <tt>appoint()</tt> method to appoint harakiri.
* Use specific <tt>appoint()</tt> method to appoint terminator.
*
* @see #appoint(int)
* @see #appoint(int,int)
*/
protected Harakiri() {}
protected Terminator() {}

/**
* One harakiri per application, or <tt>null</tt> (by default).
* One terminator per application, or <tt>null</tt> (by default).
*/
private static Thread harakiri = null;
private static Thread terminator = null;

/**
* <p>Return timeout (or waittime) value munus the margin
@@ -108,11 +108,11 @@ public static int parseAppointment(String args[]) {
}

/**
* Appoint harakiri after the given amount of <tt>minutes</tt>,
* Appoint terminator after the given amount of <tt>minutes</tt>,
* so that exit status would be 95 (to simulate JCK-like PASS
* status).
*
* @throws IllegalStateException If harakiri is already appointed.
* @throws IllegalStateException If terminator is already appointed.
*
* @see #appoint(int,int)
* @see #parseAppointment(String[])
@@ -122,23 +122,23 @@ public static void appoint(int minutes) {
}

/**
* Appoint Harakiri for the given amount of <tt>minutes</tt>,
* Appoint Terminator for the given amount of <tt>minutes</tt>,
* so that the given <tt>status</tt> would be exited when time
* is over.
*
* @throws IllegalStateException If harakiri is already appointed.
* @throws IllegalStateException If terminator is already appointed.
*
* @see #appoint(int)
* @see #parseAppointment(String[])
*/
public static void appoint(int minutes, int status) {
if (harakiri != null)
throw new IllegalStateException("Harakiri is already appointed.");
if (terminator != null)
throw new IllegalStateException("Terminator is already appointed.");

final long timeToExit = System.currentTimeMillis() + 60*1000L*minutes;
final int exitStatus = status;

harakiri = new Thread(Harakiri.class.getName()) {
terminator = new Thread(Terminator.class.getName()) {
public void run() {
long timeToSleep = timeToExit - System.currentTimeMillis();
if (timeToSleep > 0)
@@ -155,21 +155,21 @@ public void run() {
} catch (InterruptedException exception) {
exception.printStackTrace(System.err);
//
// OOPS, the dagger for harakiri looks broken:
// OOPS, the dagger for terminator looks broken:
//
return;
};
//
// OK, lets do it now:
//
System.err.println(
"#\n# Harakiri: prescheduled program termination.\n#");
System.exit(exitStatus); // harakiri to all threads
"#\n# Terminator: prescheduled program termination.\n#");
System.exit(exitStatus); // terminator to all threads
}
};

harakiri.setPriority(Thread.MAX_PRIORITY);
harakiri.setDaemon(true);
harakiri.start();
terminator.setPriority(Thread.MAX_PRIORITY);
terminator.setDaemon(true);
terminator.start();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
package nsk.stress.stack;


import nsk.share.Harakiri;
import nsk.share.Terminator;

import java.io.PrintStream;

@@ -82,7 +82,7 @@ public static int run(String args[], PrintStream out) {
else if (args[i].toLowerCase().equals("-eager"))
eager = true;
if (!eager)
Harakiri.appoint(Harakiri.parseAppointment(args));
Terminator.appoint(Terminator.parseAppointment(args));
stack016.out = out;
stack016 test = new stack016();
return test.doRun();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
package nsk.stress.stack;


import nsk.share.Harakiri;
import nsk.share.Terminator;

import java.io.PrintStream;

@@ -73,7 +73,7 @@ public static int run(String args[], PrintStream out) {
else if (args[i].toLowerCase().equals("-eager"))
eager = true;
if (!eager)
Harakiri.appoint(Harakiri.parseAppointment(args));
Terminator.appoint(Terminator.parseAppointment(args));
stack017.out = out;
stack017 test = new stack017();
return test.doRun();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
package nsk.stress.stack;


import nsk.share.Harakiri;
import nsk.share.Terminator;

import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
@@ -81,7 +81,7 @@ public static int run(String args[], PrintStream out) {
else if (args[i].toLowerCase().equals("-eager"))
eager = true;
if (!eager)
Harakiri.appoint(Harakiri.parseAppointment(args));
Terminator.appoint(Terminator.parseAppointment(args));
stack018.out = out;
stack018 test = new stack018();
return test.doRun();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
package nsk.stress.stack;


import nsk.share.Harakiri;
import nsk.share.Terminator;

import java.io.PrintStream;

@@ -69,7 +69,7 @@ public static int run(String args[], PrintStream out) {
else if (args[i].toLowerCase().equals("-eager"))
eager = true;
if (!eager)
Harakiri.appoint(Harakiri.parseAppointment(args));
Terminator.appoint(Terminator.parseAppointment(args));
//
// Measure recursive depth before stack overflow:
//

0 comments on commit 9b73fb1

Please sign in to comment.