示例#1
0
文件: util.py 项目: acardona/scripts
 def __init__(self, fn, maxsize=30):
     self.fn = fn
     # Synchronize map to ensure correctness in a multi-threaded application:
     # (I.e. concurrent threads will wait on each other to access the cache)
     self.m = Collections.synchronizedMap(
         LRUCache(maxsize, eldestFn=lambda ref: ref.clear()))
     self.locks = Collections.synchronizedMap(HashMap())
示例#2
0
def onInit():
    global eventCounter
    # Variables for assertions only
    eventCounter = Collections.synchronizedMap(HashMap())
    eventCounter.put("blue", AtomicInteger(0))
    eventCounter.put("red", AtomicInteger(0))
    sponge.setVariable("eventCounter", eventCounter)
示例#3
0
def onInit():
    global events
    # Variables for assertions only
    events = Collections.synchronizedMap(HashMap())
    events.put("defaultClonePolicy", ArrayList())
    events.put("deepClonePolicy", ArrayList())
    events.put("shallowClonePolicy", ArrayList())
    sponge.setVariable("events", events)
def onInit():
    global running
    running = Collections.synchronizedMap(LinkedHashMap())
    running.put("Rule1", AtomicBoolean(False))
    running.put("Rule2", AtomicBoolean(False))
    running.put("Rule3", AtomicBoolean(False))
    running.put("Rule4", AtomicBoolean(False))
    sponge.setVariable("testStatus", None)
示例#5
0
def onInit():
    global eventCounter
    # Variables for assertions only
    eventCounter = Collections.synchronizedMap(HashMap())
    eventCounter.put("Trigger1, file1", AtomicInteger(0))
    eventCounter.put("Trigger2, file1", AtomicInteger(0))
    eventCounter.put("Trigger1, file2", AtomicInteger(0))
    eventCounter.put("Trigger2, file2", AtomicInteger(0))
    eventCounter.put("Trigger1, file3", AtomicInteger(0))
    eventCounter.put("Trigger3, file3", AtomicInteger(0))
    sponge.setVariable("eventCounter", eventCounter)
示例#6
0
    def setName(self, name):
        self._thread.setName(str(name))

    def isAlive(self):
        return self._thread.isAlive()

    def isDaemon(self):
        return self._thread.isDaemon()

    def setDaemon(self, daemonic):
        self._thread.setDaemon(bool(daemonic))

# relies on the fact that this is a CHM
_threads = weakref.WeakValueDictionary()
_active = _threads
_jthread_to_pythread = Collections.synchronizedMap(WeakHashMap())

class Thread(JavaThread):
    def __init__(self, group=None, target=None, name=None, args=None, kwargs=None):
        assert group is None, "group argument must be None for now"
        _thread = self._create_thread()
        JavaThread.__init__(self, _thread)
        if args is None:
            args = ()
        if kwargs is None:
            kwargs = {}
        self._target = target
        self._args = args
        self._kwargs = kwargs
        if name:
            self._thread.setName(str(name))
def onInit():
    # Variables for assertions only
    sponge.setVariable("hostStatus", Collections.synchronizedMap(HashMap()))
示例#8
0
        self._thread.setName(str(name))

    def isAlive(self):
        return self._thread.isAlive()

    def isDaemon(self):
        return self._thread.isDaemon()

    def setDaemon(self, daemonic):
        self._thread.setDaemon(bool(daemonic))


# relies on the fact that this is a CHM
_threads = weakref.WeakValueDictionary()
_active = _threads
_jthread_to_pythread = Collections.synchronizedMap(WeakHashMap())


class Thread(JavaThread):
    def __init__(self,
                 group=None,
                 target=None,
                 name=None,
                 args=None,
                 kwargs=None):
        assert group is None, "group argument must be None for now"
        _thread = self._create_thread()
        JavaThread.__init__(self, _thread)
        if args is None:
            args = ()
        if kwargs is None:
示例#9
0
def onInit():
    # Variables for assertions only
    sponge.setVariable("hardwareFailureScriptCount", AtomicInteger(0))
    sponge.setVariable("hardwareFailureScriptFinishCount", AtomicInteger(0))
    sponge.setVariable("eventLogs",
                       Collections.synchronizedMap(LinkedHashMap()))