Adding TAG to EMR Cluster - emr

I am launching emr cluster using Java API but not able to associate a tag to it. Pl can you help me on this.
Using EMR CLI, it is very easy as below but I have to do this using my Java code
./elastic-mapreduce --create --alive --tag tagKey=stackOverflow
If you need more details on this, pl let me know..
Thanks in advance.
Regards,
Vineet

In earlier versions of EMR Java SDK there wasn't a way to add tags(not a direct one for sure) to add tags, but in newer versions of the Java SDK for EMR, there is a method named addTags(Collection<Tag> tags), using which you can add tags to the resources(EC2) being launched as part of the EMR cluster.
You would use it as follows:
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonElasticMapReduce emr = new AmazonElasticMapReduceClient(credentials);
List<Tag> tags = new ArrayList<Tag>();
Tag stackOverflowTag = new Tag();
stackOverflowTag.setKey("stackOverflow");
tags.add(stackOverflowTag);
AddTagsRequest addTagsRequest = new AddTagsRequest();
addTagsRequest.setTags(tags);
emr.addTags(addTagsRequest);
StepFactory stepFactory = new StepFactory();
// set up the cluster to launch and add steps
RunJobFlowResult result = emr.runJobFlow(request);
Use com.amazonaws.services.elasticmapreduce.model.Tag class in order to create tags, as there are many Tag classes present in the SDK, and for a moment I had imported the wrong one as well.
Read the doc here.

Related

alfresco - how to add a nodeRef as the new version of another node using java?

Hi I am new to alfresco so i appreciate your help.
I am trying to add a new node ref as the new version of a document while editing his properties.
My scenario
i can create a PDF file with his properties as the content,after updating his properties, I am doing this with behavior/policies NodeServicePolicies.OnUpdateNodePolicy .
example: when i edit the name I can see it inside the PDF file
But this new file needs to be the new version of the file edited, i cant figure how to fix this.
i appreciate yours answer.
thanks in advance.
https://docs.alfresco.com/4.0/concepts/versioning.html
You're looking for versioning.
Like Curtis mentioned, using API is an option, but Alfresco will do this for you automatically if you set it up that way. Also, creating a new version will not change node's nodeRef.
See the createVersion method from the VersionService API here
My fix:
i just added get the content of the new file and set as the new content of the previous node. like this
void updateVersionWithNewNodeContent(nodeA){ // nodeB is the new version of the file. NodeRef nodeB; nodeService.setProperty(nodeA, ContentModel.PROP_CONTENT,nodeService.getProperty(nodeB, ContentModel.PROP_CONTENT)); }

How to use `migration.jar` in Corda Enterprise 4 to run tests?

While using Corda Enterprise 4.2, we have managed to create a
biz-generated-migration....jar which seems to be a pre-requisite to everything, even
when using an H2 database. We were not able to use this .jar file
while executing our tests, even when referencing this brand new .jar
file in our test setup, like this:
val BIZ_COMPONENT_VERSION="1.0.0"
val DEFAULT_MOCK_NETWORK = MockNetwork(
cordappPackages = listOf(
"package.subpkg-infra.cd.contract",
"package.subpkg-infra.contract",
"package.subpkg-infra.flow",
"package.subpkg-infra.cd.flow",
"package.subpkg-infra.cd.pend.flow",
"package.subpkg-infra.schema",
"package.subpkg-cordapp:biz-generated-migration:$BIZ_COMPONENT_VERSION",
"package.subpkg-cordapp:biz-component-base:$BIZ_COMPONENT_VERSION",
"package.subpkg-cordapp:biz-component-core:$BIZ_COMPONENT_VERSION",
"package.subpkg-cordapp:biz-component-interact:$BIZ_COMPONENT_VERSION"
),
notarySpecs = listOf(MockNetworkNotarySpec(DUMMY_NOTARY_NAME)))
Every test fails, complaining about not finding the migration for the
schema.
How can we accomplish to use this generated migration.jar file to
enable our testing ? Or is this approach completely misused ?
Following options have been suggested to fix the issue.
Have you overridden the "migrationResourse"="migration/filename" of MappedSchema class.
make sure to proper XML so this would be not H2 specific.
also could you try to use below network = MockNetwork(MockNetworkParameters(listOf( findCordapp("com.deqode.contracts"), findCordapp("com.deqode.flows"))) ) instead of cordappPackages.
Can you confirm if you are using Windows

How do I add an Apps Script Library to AppMaker?

I created this script to determine if the Session.getScriptTimeZone() would draw the time zone from the library file rather than AppMaker. Here's the script:
function getFormattedDateString(dt,format){
var format=format||"E MMM dd, yyyy HH:mm";
var dt=dt||new Date();
return Utilities.formatDate(new Date(dt), Session.getScriptTimeZone(), format);
}
I tested it in another script with the following code:
function test(){
Logger.log(AMSLib.getFormattedDateString(new Date()));
}
I went into AppMaker and this dialog:
I've tried the Script ID from here:
I've also tried several deployment ID's from the publish from Manifest dialog and I keep getting the same answer:
I've also tried the Project Key which is used with other apps scripts to load libraries.
I don't know what to try next.
First things first, you need to publish your Apps Script app, after that it'll be assigned Script ID(by the way it can also be found in the published app URL). Once you have Script ID, you can specify it in App Maker and select library version you want to use:
To access library's functions you need to use name specified in the object setting:
// Server side library call
var result = MyLibraryName.doSomeCoolStuff();
App Maker should be smart enough and pickup all library's public functions for autocomplete.
Learn more:
https://developers.google.com/apps-script/guides/libraries
https://developers.google.com/appmaker/scripting/libraries
That's really odd to not have a script key there. You might make a copy of your script, something might be corrupted. You can also get the key from the URL ex: https://script.google.com/a/ignitesynergy.com/d/1oHnk_xl76KagGS4g7O2pC1MM4R3iZR8-7FlmzKXxRDtO1o5nDU2/edit
Remember to File-> Manage Versions and create a version. You also need to set the sharing to public.

How to run Openstack-Swift java api?

I try to run Openstack-Swift java sdk sample.
I have swift and keystone project to use swift only.
I found this project : https://github.com/woorea/openstack-java-sdk
But, I don't know how to run this project in Window Eclipse.
Should I build all project(nova, etc..) in maven?
Do you know how to run this project or website that post run-way in regular sequence?
#stream
I have not tried Woorea but i know a lot many developers are using Jclouds, the link http://developer.rackspace.com/#home-sdks has well documented guide with example how to use the Java SDK.
Hope it helps.
looks like you can build SWIFT independently (part of woorea peoject)
as it states in the readme file here:
(com.woorea swift-client 3.0.0-SNAPSHOT)
https://github.com/woorea/openstack-java-sdk
the Maven artifact ID should be:
openstack-java-sdk
Here is a nice toturial that can be of hand:
https://github.com/woorea/openstack-java-sdk/wiki/Swift-Tutorial
it has the example for the java api for using SWIFT,
for example, this code snippet (more details in the link):
Properties properties = System.getProperties();
properties.put("verbose", "true");
properties.put("auth.credentials", "passwordCredentials");
properties.put("auth.username", "demo");
properties.put("auth.password", "secret0");
properties.put("auth.tenantName", "demo");
properties.put("identity.endpoint.publicURL","http://192.168.1.43:5000/v2.0");
OpenStackClient openstack = OpenStackClient.authenticate(properties);
AccountResource account = openstack.getStorageEndpoint();
account.container("hellocontainer").put();
account.container("hellocontainer").object("dir1").put();
account.container("hellocontainer").object("test1")
.put(new File("pom.xml"), new SwiftStorageObjectProperties() {{
setContentType("application/xml");
getCustomProperties().putAll(new HashMap<String, String>() {{
put("customkey.1", "customvalue.1");
}});
}});
List<SwiftStorageObject> objects = account.container("hellocontainer").get();
just keep in mind that when using openstack's API you will most likely need to authenticate (get tokens etc..) so that you will need the Keystone lib as well
www.programcreek.com/java-api-examples/index.php?api=com.woorea.openstack.keystone.Keystone
hope this helps.

How to change an emr job configuration using c# awssdk api

I want the output for my reducer to be zipped (preferably gzip).
I am successfully able to launch an EMR job using the c# awssdk but do not know how to change the job confiugration for desired result.
I understand i need to set the following property for the emr job
mapred.output.compress: true
how do i do this in c# code?
also how do I make it produce gzip files?
Thanks
String[] zipArgs = new [] { "-jobconf", "mapred.output.compress=true"};
HadoopJarStepConfig config = new StreamingStep()
.WithInputs()
.WithOutput()
.WithMapper()
.WithReducer()
.ToHadoopJarStepConfig()
.WithArgs(zipArgs)
;
you can find more info at
http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-plan-output-compression.html

Resources