I'm trying to start a spark streaming job on mesos using the DCOS cli.
I'm able to start the job. My program expects a config file to be passed as cli parameter. How do I achieve this with dcos spark run --submit-args?
I tried --files http://server/path/to//file hoping it will download files but that didn't work. Driver starts but fails because config file is missing.
I also tried to roll up the jar and config file as tar and submitted it. I can see in Mesos logs that the tar was fetched and untar. Both config and jar file are seen in the working directory. But job fails with ClassNotFoundException. I suspect something was not right about how spark-submit was started.
dcos spark run --submit-args="--supervise --deploy-mode cluster --class package.name.classname http://file-server:8000/Streaming.tar.gz Streaming.conf"
Any hint on how to proceed? Also, in which log file can I see the underlying spark-submit command used by DCOS?
Here is the example of a command you should launch in order to make it work:
dcos spark run --submit-args='--conf spark.mesos.uris=https://s3-us-west-2.amazonaws.com/andrey-so-36323287/pi.conf --class JavaSparkPiConf https://s3-us-west-2.amazonaws.com/andrey-so-36323287/sparkPi_without_config_file.jar /mnt/mesos/sandbox/pi.conf'
Where
--conf spark.mesos.uris=... A comma-separated list of URIs to be downloaded to the sandbox when driver or executor is launched by Mesos. This applies to both coarse-grained and fine-grained mode.
/mnt/mesos/sandbox/pi.conf A path to the downloaded file which your main class receives as a 0th parameter (see the code snippet below). /mnt/mesos/sandbox/ is a standard path inside a container which is mapped to a corespondent mesos-task sandbox.
public final class JavaSparkPiConf {
public static void main(String[] args) throws Exception {
SparkConf sparkConf = new SparkConf().setAppName("JavaSparkPi");
JavaSparkContext jsc = new JavaSparkContext(sparkConf);
Scanner scanner = new Scanner(new FileInputStream(args[0]));
int slices;
if (scanner.hasNextInt()) {
slices = scanner.nextInt();
} else {
slices = 2;
}
int n = 100000 * slices;
List<Integer> l = new ArrayList<>(n);
for (int i = 0; i < n; i++) {
l.add(i);
}
JavaRDD<Integer> dataSet = jsc.parallelize(l, slices);
int count = dataSet.map(new Function<Integer, Integer>() {
#Override
public Integer call(Integer integer) {
double x = Math.random() * 2 - 1;
double y = Math.random() * 2 - 1;
return (x * x + y * y < 1) ? 1 : 0;
}
}).reduce(new Function2<Integer, Integer, Integer>() {
#Override
public Integer call(Integer integer, Integer integer2) {
return integer + integer2;
}
});
System.out.println("Pi is roughly " + 4.0 * count / n);
jsc.stop();
}
}
Streaming.conf is just a string that will be passed to your driver. Your driver must be able to see it. The easiest way to do this is to place it in an accessible location, the specify that you want it downloaded to the sandbox via spark.mesos.uris [1]. You could alternately write your application to support reading from a remote location, and just pass the location on the CLI.
--files is used to place files at the executors, but you're trying to pass a file to the driver, so that won't work.
[1] http://spark.apache.org/docs/latest/running-on-mesos.html
Michael Gummelt
Mesosphere
Related
Is there a way to determine if a Windows-process is run as a service ? Is there any fixed parent-process of all the services which I can identify to assure that the process is a service-process.
if application designed for run both as service and as standalone application, the best way know how application started - use command line. when you register service with CreateServiceW - pass to lpBinaryPathName some arguments. and then on start - check string returned by GetCommandLineW() - are this arguments present. if yes - you run as service, if no - as standalone application.
for example append \n symbol to the service binary file path :
WCHAR BinaryPathName[MAX_PATH + 3];
ULONG cch = GetModuleFileNameW(0, BinaryPathName + 1, _countof(BinaryPathName) - 3);
if (GetLastError() == NOERROR)
{
BinaryPathName[0] = '\"';
BinaryPathName[cch + 1] = '\"';
BinaryPathName[cch + 2] = '\n';
BinaryPathName[cch + 3] = 0;
//CreateServiceW(.., BinaryPathName, ..);
}
(\n selected because this symbol can not be in command line if exec application manually )
and then in application entry point do very simply and fast check
if (wcschr(GetCommandLineW(), '\n'))
{
const static SERVICE_TABLE_ENTRY ste[] = { { L"my_service_name", ServiceMain }, {} };
StartServiceCtrlDispatcher(ste);
}
else
{
// run as standalone application
}
i think this solution is the best. however possible and others. for example we can do next check:
ULONG SessionId;
if (ProcessIdToSessionId(GetCurrentProcessId(), &SessionId) &&
WTSGetActiveConsoleSessionId() == SessionId)
{
// we not run as service;
}
I am trying to get a value (iatDistribution) from the .ini file to run in the simulation but it will not work.
I have tried hard-coding a value in and it works. But using the variable it won't work.
.cc File
void PacketGen::initialize()
{
int seqno = 0;
int txId = getParentModule()->par("nodeId");
int messageSize = par("messageSize");
double distro = par("iatDistribution");
scheduleAt(simTime(), new cMessage); //sends the initial message!
}
void PacketGen::handleMessage(cMessage *msg)
{
appMessage* message = createMessage();
send(message, "out0");
scheduleAt((distro + simTime()), msg);
}
.ini File
#Gen & Sink
simulation.TXNode[*].packGen.messageSize = 64
simulation.TXNode[*].packGen.iatDistribution = 0.1
packGen.ned file
simple PacketGen
{
parameters:
int messageSize;
double iatDistribution;
gates:
output out0;
}
When a value like 0.1 replaces distro in the scheduleAt((distro + simTime()), msg); line, the simulation time increases but when trying to use the distro variable it does not.
In initialize() you assigned the value of parameter iatDistribution into local variable distro. And probably you have declared variable distro as a member of PacketGen class.
Therefore change the line:
double distro = par("iatDistribution");
into:
distro = par("iatDistribution");
I read JMeter's manual and saw that there is __uuid() function for JMeter. It allows to generate UUID type 4 for JMeter tests. Is it possible to generate UUIDv1 in JMeter or maybe some plugin exists.
I would recommend taking the following steps:
Download Jug library (for example from here) and drop the .jar somewhere to JMeter Classpath
Restart JMeter to pick the .jar up
Once done you should be able to generate UUIDv1 using JSR223 Test Elements and Groovy language like:
import com.fasterxml.uuid.EthernetAddress
import com.fasterxml.uuid.Generators
import com.fasterxml.uuid.impl.TimeBasedGenerator
def addr = EthernetAddress.fromInterface()
def gen = Generators.timeBasedGenerator(addr)
def v1uuid = gen.generate()
log.info(v1uuid.toString())
Demo:
References:
Generating version 1 UUIDs
Groovy is the New Black
In jmeter you can add JSR 223 Sampler choose Java language and execute java code for UUID version 1:
String timeuuid = com.datastax.driver.core.utils.UUIDs.timeBased().toString();
And then add it to Jmeter variable:
vars.put("myUUID", timeuuid);
First, we'll generate the 64 least and most significant bits as long values:
private static long get64LeastSignificantBitsForVersion1() {
Random random = new Random();
long random63BitLong = random.nextLong() & 0x3FFFFFFFFFFFFFFFL;
long variant3BitFlag = 0x8000000000000000L;
return random63BitLong + variant3BitFlag;
}
private static long get64MostSignificantBitsForVersion1() {
LocalDateTime start = LocalDateTime.of(1582, 10, 15, 0, 0, 0);
Duration duration = Duration.between(start, LocalDateTime.now());
long seconds = duration.getSeconds();
long nanos = duration.getNano();
long timeForUuidIn100Nanos = seconds * 10000000 + nanos * 100;
long least12SignificatBitOfTime = (timeForUuidIn100Nanos & 0x000000000000FFFFL) >> 4;
long version = 1 << 12;
return
(timeForUuidIn100Nanos & 0xFFFFFFFFFFFF0000L) + version + least12SignificatBitOfTime;
}
We can then pass these two values to the constructor of the UUID:
public static UUID generateType1UUID() {
long most64SigBits = get64MostSignificantBitsForVersion1();
long least64SigBits = get64LeastSignificantBitsForVersion1();
return new UUID(most64SigBits, least64SigBits);
}
I am trying to run the jmeter nongui command using java as follows:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\apache-jmeter-2.13\\bin\\jmeter.bat -t \"C:\\jmeter scripts\\test.jmx\" -n -l \"C:\\jmeter scripts\\nonGUI.csv\"");
It runs perfectly fine, until I add the argument:
-Jusers=15 inside the command mentioned above in the next run.
The property set for the number of threads is: ${__P(users,10)}
The result file does not seem to fill up and the process seems to run forever under the CPU Resource monitor.
P.S.: Please do not suggest me to run the jmeter file using the steps given in the blazemeter website. It has used one of the deprecated method and there is no resolution given for the plausible runtime errors in that website.
I was not able to reproduce your error, but here is a complete example with JMX File. I removed the need for the "".
// OSX exmaple
public class r {
public static void main(String[] args) throws Exception {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("/usr/local/bin/jmeter -t /Users/rfriedman/jmeter/SimpleUrl.jmx -Jusers=15 -n -l /Users/rfriedman/jmeter/nonGUI.csv");
}
}
Just to make sure I ran modified on Windows as well
// Windows Example
public class r {
public static void main(String[] args) throws Exception {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\Users\\rfriedman\\Desktop\\apache-jmeter-2.13\\bin\\jmeter.bat -t C:\\Users\\rfriedman\\Desktop\\SimpleUrl.jmx -Jusers=20 -n -l C:\\Users\\rfriedman\\Desktop\\nonGUI.csv");
}
}
JMeter Test Plan
It works after I add the property value for Synchronization timer similar to Thread count.
Also, if I have to pass the value of -Jusers in the form of variable, how to do it? I am trying to do the following. But it's not getting executed.
eg:
int value=10;
Process pr = rt.exec("C:\Users\rfriedman\Desktop\apache-jmeter-2.13\bin\jmeter.bat -t C:\Users\rfriedman\Desktop\SimpleUrl.jmx -Jusers=value -n -l C:\Users\rfriedman\Desktop\nonGUI.csv");
Update:
I tried with String value="10"; as well. Still the jmeter logs says:
"jmeter.reporters.Summariser: summary = 0 in 0s = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0.00%)"
Use this snippet.
int value = 10;
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\apache-jmeter-2.13\\bin\\jmeter.bat" +
" -t \"C:\\jmeter scripts\\test.jmx\" -Jusers=" + value + " -Jsync=" + value +
" -n -l \"C:\\jmeter scripts\\nonGUI.csv\" -j \"C:\\jmeter scripts\\jmeterLogs.log\"");
I am using an external .txt file to save the incrementing name index for whenever someone "takes a picture" in my app (i.e. image_1.jpg, image_2.jpg, etc...). I am trying to save the data externally so that a user does not overwrite their pictures each time they run the program. However, because of the way that Processing packages its contents for export I cannot both read and write to the same file. It reads the appropriate file located in the apps package contents, however, when it tries to write to that file, it creates a new folder in the same directory as the app itself and writes to a new file with the same name instead.
Essentially, it reads the proper file but refuses to write to it, instead making a copy and writing to that one. The app runs fine but every time you open it and take pictures you overwrite the images you already had.
I have tried naming the "write to" location the explicitly same link as where the exported app stores the data folder inside the package contents (Contents/Resources/Java/data/assets) but this creates a copy of this directory in the same file as the app.
I have also tried excluding the file I am trying to read/write from my data folder when I export the app by changing the read code to ../storage/pictureNumber.txt and then putting this file next to app itself. When I do this the app doesn't launch at all because it is looking in its own data folder for storage and refuses to go outside of itself with ../ . Has anyone had luck both reading from and writing to the same file in an exported processing .app?
Here is the code for the class that is handling the loading and saving of the file:
class Camera {
PImage cameraImage;
int cameraPadding = 10;
int cameraWidth = 60;
int opacity = 0;
int flashDecrementer = 50; //higher number means quicker flash
int pictureName;
Camera() {
String[] pictureIndex = loadStrings("assets/pictureNumber.txt");
pictureName = int(pictureIndex[0]);
cameraImage = loadImage("assets/camera.jpg");
String _pictureName = "" + char(pictureName);
println(pictureName);
}
void display(float mx, float my) {
image(cameraImage, cameraPadding, cameraPadding,
cameraWidth, cameraWidth-cameraWidth/5);
}
boolean isOver(float mx, float my) {
if (mx >= cameraPadding &&
mx <= cameraPadding+cameraWidth &&
my >= cameraPadding &&
my <= cameraPadding+cameraWidth-cameraWidth/5) {
return true;
}
else {
return false;
}
}
void captureImage() {
save("pictures/"+lines.picturePrefix+"_"+pictureName+".jpg");
pictureName++;
String _null = "";
// String _tempPictureName = _null.valueOf(pictureName);
String[] _pictureName = {_null.valueOf(pictureName)};
saveStrings("assets/pictureNumber.txt", _pictureName);
println(_pictureName);
}
void flash() {
fill(255, opacity);
rect(0,0,width,height);
opacity -= flashDecrementer;
if(opacity <= 0) opacity = 0;
}
}
After a lot of searching I found that you have to use savePath() in order to read from a directory outside of the project.jar. The camera class constructor now looks like this:
path = savePath("storage");
println(path);
String[] pictureIndex = loadStrings(path+"/pictureNumber.txt");
pictureName = int(pictureIndex[0]);
cameraImage = loadImage("assets/camera.jpg");
String _pictureName = ""+char(pictureName);
and everything works!