Gpars withExistingPool Error jsr166y.ForkJoinPool not found - multithreading

I have updated from 'org.codehaus.gpars:gpars:1.0.0' to 'org.codehaus.gpars:gpars:1.1.0'. My code works fine in 1.0.0 but in version 1.1.0 I cannot find jsr166y.ForkJoinPool anymore.
How do I get the correct ForkJoinPool?
The code I am using is:
import groovyx.gpars.GParsPool
import jsr166y.ForkJoinPool
class Test {
def pool = new ForkJoinPool()
def executeAsync(args, closure = null) {
if(!closure) {
closure = args
args = null
}
GParsPool.withExistingPool(pool) {
closure.callAsync(args)
}
}
}
I have to import java.util.concurrent.ForkJoinPool to get the ForkJoinPool class. But at runtime I get the following error:
| Error 2013-08-01 13:26:45,807 [http-nio-8080-exec-4] ERROR
errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing
request: [POST] /testpackage/test/saveAll - parameters:
jsr166y.ForkJoinPool. Stacktrace follows:
Message: jsr166y.ForkJoinPool
Line | Method
->> 175 | findClass in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 423 | loadClass in java.lang.ClassLoader
| 147 | loadClass . . . . . . . . in org.codehaus.groovy.tools.RootLoader
| 356 | loadClass in java.lang.ClassLoader
| 2451 | privateGetDeclaredMethods in java.lang.Class
| 1810 | getDeclaredMethods in ''
| 46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
| 33 | get in ''
| 318 | saveAll . . . . . . . . . in testpackage.UploadImageController
| 195 | doFilter in
grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
| Compiling 1 source files.

Update your BuildConfog.groovy as:
compile 'org.codehaus.gpars:gpars:1.1.0'
compile 'org.codehaus.jsr166-mirror:jsr166y:1.7.0'
This should work for you.

Related

Bitbucket Pipelines export into variable using jq and xq causes error

When i running a pipeline in bitbucket i want to export into variable using
export APEX_CLASSES=$(xq . < package/package.xml | jq '.Package.types | [.] | flatten | map(select(.name=="ApexClass")) | .[] | .members | [.] | flatten | map(select(. | index("*") | not)) | unique | join(",")' -r)
but i got error in pipeline
parse error: Invalid numeric literal at line 1, column 5
i tried to identify a error but i always get same error :(
When i add a escape \ before " i got this error
jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at <top-level>, line 1:
.Package.types | [.] | flatten | map(select(.name==\"ApexClass\")) | .[] | .members | [.] | flatten | map(select(. | index(\"*\") | not)) | unique | join(\",\")
jq: 1 compile error
This is package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AccountHelper</members>
<members>BoatHelper</members>
<members>CaseHelper</members>
<name>ApexClass</name>
</types>
<version>57.0</version>
</Package>

Unable to connect to the PYMQI Client facing FAILED: MQRC_ENVIRONMENT_ERROR

I am getting the below error while connecting to IBM MQ using library pymqi.
Its a clustered MQ channel
Traceback (most recent call last):
File "postToQueue.py", line 432, in <module>
qmgr = pymqi.connect(queue_manager, channel, conn_info)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 2608, in connect
qmgr.connect_tcp_client(queue_manager or '', CD(), channel, conn_info, user, password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1441, in connect_tcp_client
self.connect_with_options(name, cd, user=user, password=password)
File "C:\Python\lib\site-packages\pymqi\__init__.py", line 1423, in connect_with_options
raise MQMIError(rv[1], rv[2])
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2012: FAILED: MQRC_ENVIRONMENT_ERROR'
Please see my code below.
queue_manager = 'quename here'
channel = 'channel name here'
host ='host-name here'
port = '2333'
queue_name = 'queue name here'
message = 'my message here'
conn_info = '%s(%s)' % (host, port)
print(conn_info)
qmgr = pymqi.connect(queue_manager, channel, conn_info)
queue = pymqi.Queue(qmgr, queue_name)
queue.put(message)
print("message sent")
queue.close()
qmgr.disconnect()
Getting error at the line below
qmgr = pymqi.connect(queue_manager, channel, conn_info)
Added the IBM client to scripts folder as well , using Windows 10 , Python 3.8.1 and IBM Client 9.1 windows client installation image, Below is the header
-----------------------------------------------------------------------------+
| |
| WebSphere MQ First Failure Symptom Report |
| ========================================= |
| |
| Date/Time :- Tue January 28 2020 16:27:51 Eastern Standard Time |
| UTC Time :- 1580246871.853000 |
| UTC Time Offset :- -300 (Eastern Standard Time) |
| Host Name :- CA-LDLD0SQ2 |
| Operating System :- Windows 10 Enterprise x64 Edition, Build 17763 |
| PIDS :- 5724H7251 |
| LVLS :- 8.0.0.11 |
| Product Long Name :- IBM MQ for Windows (x64 platform) |
| Vendor :- IBM |
| O/S Registered :- 0 |
| Data Path :- C:\Python\Scripts\IBM |
| Installation Path :- C:\Python |
| Installation Name :- MQNI08000011 (126) |
| License Type :- Unknown |
| Probe Id :- XC207013 |
| Application Name :- MQM |
| Component :- xxxInitialize |
| SCCS Info :- F:\build\slot1\p800_P\src\lib\cs\amqxeida.c, |
| Line Number :- 5085 |
| Build Date :- Dec 12 2018 |
| Build Level :- p800-011-181212.1 |
| Build Type :- IKAP - (Production) |
| UserID :- alekhya.machiraju |
| Process Name :- C:\Python\python.exe |
| Arguments :- |
| Addressing mode :- 32-bit |
| Process :- 00010908 |
| Thread :- 00000001 |
| Session :- 00000001 |
| UserApp :- TRUE |
| Last HQC :- 0.0.0-0 |
| Last HSHMEMB :- 0.0.0-0 |
| Last ObjectName :- |
| Major Errorcode :- xecF_E_UNEXPECTED_SYSTEM_RC |
| Minor Errorcode :- OK |
| Probe Type :- INCORROUT |
| Probe Severity :- 2 |
| Probe Description :- AMQ6090: MQM could not display the text for error |
| 536895781. |
| FDCSequenceNumber :- 0 |
| Comment1 :- WinNT error 1082155270 from Open ccsid.tbl. |
| |
+-----------------------------------------------------------------------------+

How can i import a class in python file from my airflow custom operator?

How can i import a class in bar.py from my operator?
i have a folder structure like this
.
+--dags
+--libs
| +--__init__.py
| +--foo
| +--__init__.py
| +--bar.py
+--plugins
| +-- foo_operators.py
In foo_operators.py
from libs.foo.bar import Client
but i got an error, it cannot find the class
How about you move libs into dags?
.
+--dags
| +--libs
| +--__init__.py
| +--foo
| +--__init__.py
| +--bar.py
+--plugins
| +-- foo_operators.py

How to include modules for code coverage for unit testing?

My assumption is that any module tested using Intern will automatically be covered by Istanbul's code coverage. For reasons unknown to me, my module is not being included.
I am:
running Intern 1.6.2 (installed with npm locally)
testing NodeJS code
using callbacks, not promises
using CommonJS modules, not AMD modules
Directory Structure (only showing relevant files):
plister
|
|--libraries
| |--file-type-support.js
|
|--tests
| |--intern.js
| |--unit
| |--file-type-support.js
|
|--node_modules
|--intern
plister/tests/intern.js
define({
useLoader: {
'host-node': 'dojo/dojo'
},
loader: {
packages: [
{name: 'libraries', location: 'libraries'}
]
},
reporters: ['console'],
suites: ['tests/unit/file-type-support'],
functionalSuites: [],
excludeInstrumentation: /^(tests|node_modules)\//
});
plister/tests/unit/file-type-support.js
define([
'intern!bdd',
'intern/chai!expect',
'intern/dojo/node!fs',
'intern/dojo/node!path',
'intern/dojo/node!stream-equal',
'intern/dojo/node!../../libraries/file-type-support'
], function (bdd, expect, fs, path, streamEqual, fileTypeSupport) {
'use strict';
bdd.describe('file-type-support', function doTest() {
bdd.it('should show that the example output.plist matches the ' +
'temp.plist generated by the module', function () {
var deferred = this.async(),
input = path.normalize('tests/resources/input.plist'),
output = path.normalize('tests/resources/output.plist'),
temporary = path.normalize('tests/resources/temp.plist');
// Test deactivate function by checking output produced by
// function against test output.
fileTypeSupport.deactivate(fs.createReadStream(input),
fs.createWriteStream(temporary),
deferred.rejectOnError(function onFinish() {
streamEqual(fs.createReadStream(output),
fs.createReadStream(temporary),
deferred.callback(function checkEqual(error, equal) {
expect(equal).to.be.true;
}));
}));
});
});
});
Output:
PASS: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (29ms)
1/1 tests passed
1/1 tests passed
Output (on failure):
FAIL: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (30ms)
AssertionError: expected true to be false
AssertionError: expected true to be false
0/1 tests passed
0/1 tests passed
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
Output (after removing excludeInstrumentation):
PASS: main - file-type-support - should show that the example output.plist matches the temp.plist generated by the module (25ms)
1/1 tests passed
1/1 tests passed
------------------------------------------+-----------+-----------+-----------+-----------+
File | % Stmts |% Branches | % Funcs | % Lines |
------------------------------------------+-----------+-----------+-----------+-----------+
node_modules/intern/ | 70 | 50 | 100 | 70 |
chai.js | 70 | 50 | 100 | 70 |
node_modules/intern/lib/ | 79.71 | 42.86 | 72.22 | 79.71 |
Test.js | 79.71 | 42.86 | 72.22 | 79.71 |
node_modules/intern/lib/interfaces/ | 80 | 50 | 63.64 | 80 |
bdd.js | 100 | 100 | 100 | 100 |
tdd.js | 76.19 | 50 | 55.56 | 76.19 |
node_modules/intern/lib/reporters/ | 56.52 | 35 | 57.14 | 56.52 |
console.js | 56.52 | 35 | 57.14 | 56.52 |
node_modules/intern/node_modules/chai/ | 37.9 | 8.73 | 26.38 | 39.34 |
chai.js | 37.9 | 8.73 | 26.38 | 39.34 |
tests/unit/ | 100 | 100 | 100 | 100 |
file-type-support.js | 100 | 100 | 100 | 100 |
------------------------------------------+-----------+-----------+-----------+-----------+
All files | 42.14 | 11.35 | 33.45 | 43.63 |
------------------------------------------+-----------+-----------+-----------+-----------+
My module passes the test and I can make it fail too. It just will not show up in the code coverage. I have done the tutorial hosted on GitHub without any problems.
I tried dissecting the Istanbul and Intern dependencies. I place a console.log where it seems files to be covered go through, but my module doesn't get passed. I have tried every variation of deferred.callback and deferred.rejectOnError with no difference to the code coverage.
Also, any feedback on my use of deferred.callback and deferred.rejectOnError will be greatly appreciated. I am still a little uncertain on their usage.
Thanks!
As of Intern 1.6, only require('vm').runInThisContext is hooked to add code coverage data, not require. Instrumentation of require was added in Intern 2.0.
The use of callback/rejectOnError in the above code is correct.

Groovy: Manipulate variable from within each

I'd like to manipulate a variable in Groovy from within the closure of each, like this:
def stringTest = ''
def foo = ['one', 'two', 'three']
foo.each {
stringTest.concat(it)
}
println stringTest
But this gives me the following error:
| Error 2013-03-13 15:26:12,330 [http-bio-8080-exec-2] ERROR
errors.GrailsExceptionResolver - NoSuchMethodError occurred when
processing request: [GET] /Reporting-Web/reporting/show/1
reporting.web.AppFiguresService$_getProductIDs_closure2.(Ljava/lang/Object;Ljava/lang/Object;Lgroovy/lang/Reference;)V.
Stacktrace follows: Message: Executing action [show] of controller
[com.xyz.reporting.ReportingController] caused exception: Runtime
error executing action Line | Method
->> 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker |
918 | run in '' ^ 680 | run . . in java.lang.Thread
Caused by ControllerExecutionException: Runtime error executing action
->> 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker |
918 | run in '' ^ 680 | run . . in java.lang.Thread
Caused by InvocationTargetException: null
->> 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker |
918 | run in '' ^ 680 | run . . in java.lang.Thread
Caused by NoSuchMethodError:
reporting.web.Foo$_getProductIDs_closure2.(Ljava/lang/Object;Ljava/lang/Object;Lgroovy/lang/Reference;)V
->> 77 | getProductIDs in reporting.web.Foo$$ENzya8Hg
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 45 | show in com.xyz.reporting.Foo | 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 |
doFilter in grails.plugin.cache.web.filter.AbstractFilter | 895 |
runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 918 |
run in '' ^ 680 | run . . in java.lang.Thread
I'm quite new to Groovy, any help would be great here!
This works...
def stringTest = ''
def foo = ['one', 'two', 'three']
foo.each {
stringTest += it
}
println stringTest
the function "concat()" returns a string:
stringTest = stringTest.concat(it)
To modify the iterator in the closure is not possible.
//Edit
The error msg is a grails error, while the controller can not open the function "show()"
Java strings are immutable. You can collect the concatened string:
def stringTest = ''
def foo = ['one', 'two', 'three']
stringTest = foo.collect { stringTest + it }.join()
assert stringTest == "onetwothree"

Resources