#JShell project for Tj-Bot!
1 messages · Page 5 of 1
That's okay, I don't think we can figure this out with your knowledge and expertise so there's always the day after
Counting on you
And what errors?
@sterile crest I'm here
no
Yes, on branch improveclose
@ebon river try this branch and you will see
run a one time session
have you pushed the branch?
yes
1 min ago nice
send me the cURL command too you were testing with
curl --request POST \
--url http://localhost:8080/jshell/single-eval \
--data 'for(int i = 5; i < 10; i++) {
System.out.println(i);
}'
And what is weird there?
I don't get any error either
what version of docker are you using?
What version of the image are you using?
I'm on Docker version 26.1.1, build 4cf5afa
v24.0.2
I pulled the repo fresh and had a clean docker with no images or containers
REPOSITORY TAG IMAGE ID CREATED SIZE
togetherjava.org:5001/togetherjava/jshellwrapper master 1dddb68cf79d 2 minutes ago 343MB
I just built this from source
Docker version 27.1.1, build 63125853e3
this is unrelated to the wrapper
it didn't change since a long time ago
What is your exception?
once he calls close the container is killed but the underlying docker thread is still open and tries to read from stdin causing it to throw an IOException with some communication link as the error message
wait 30s please
the SDK creates a thread under the hood, at least for:
public InputStream startAndAttachToContainer(String containerId, InputStream stdin)
throws IOException {
PipedInputStream pipeIn = new PipedInputStream();
PipedOutputStream pipeOut = new PipedOutputStream(pipeIn);
client.attachContainerCmd(containerId)
.withLogs(true)
.withFollowStream(true)
.withStdOut(true)
.withStdErr(true)
.withStdIn(stdin)
.exec(new ResultCallback.Adapter<>() {
@Override
public void onNext(Frame object) {
try {
String payloadString =
new String(object.getPayload(), StandardCharsets.UTF_8);
if (object.getStreamType() == StreamType.STDOUT) {
pipeOut.write(object.getPayload());
} else {
LOGGER.warn("Received STDERR from container {}: {}", containerId,
payloadString);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
client.startContainerCmd(containerId).exec();
return pipeIn;
}
java.io.IOException: java.io.IOException: Le canal de communication a �t� ferm�
at java.base/java.nio.channels.Channels$1.read(Channels.java:166) ~[na:na]
at org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:149) ~[httpcore5-5.2.4.jar:5.2.4]
at org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:172) ~[httpcore5-5.2.4.jar:5.2.4]
at org.apache.hc.core5.http.impl.io.IdentityInputStream.read(IdentityInputStream.java:91) ~[httpcore5-5.2.4.jar:5.2.4]
at org.apache.hc.core5.http.io.EofSensorInputStream.read(EofSensorInputStream.java:118) ~[httpcore5-5.2.4.jar:5.2.4]
at com.github.dockerjava.core.FramedInputStreamConsumer.accept(FramedInputStreamConsumer.java:30) ~[docker-java-core-3.3.6.jar:na]
at com.github.dockerjava.core.FramedInputStreamConsumer.accept(FramedInputStreamConsumer.java:12) ~[docker-java-core-3.3.6.jar:na]
at com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:275) ~[docker-java-core-3.3.6.jar:na]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
Caused by: java.io.IOException: Le canal de communication a �t� ferm�
at java.base/sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:299) ~[na:na]
at java.base/sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:389) ~[na:na]
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
... 1 common frames omitted
@ebon river
update your docker version @timber mirage just to entertain me 😄
@ebon river the thread name is "docker-java-stream--676896705"
I mean you could be a good boy and close the stream properly before killing the container
But apart from that I am not sure you can handle this gracefully
Doesn't work
How did you try that?
I mean, the remote end probably disappears when the container closes
But maybe newer docker daemons are nicer about it
Updating might be worth a shot
Your docker is ~a year old
With 24.0.9?
v27.1.1
or 27.x?
ala, i'll jump in vc - check that my steps are the same as yours?
which steps ?
my repro steps
which steps ?
bruh
steps are literally
reproduction steps
if this isn't an issue for me and instan and it's not appearing on the vps
it's a you problem
We don't know if it is happening on the vps
it's still a you-problem
Yea
but in any case, ignore the exception, there's nothing you can do besides thread.join
And then the error is swallowed
you probably don't want to thread.join because i'm not sure what's happening under the hood
I am not sure there is anything you can do honestly
At some random point your remote end disappears and you have no idea when or why
if it's a new thread per container, then you can otherwise, just swallow the error and leave it
If you make a funny handshake close protocol you could store the closable in onStart and invoke it, ending the attachment stream
And only then exit the container
Simplest solution there is probably to make the container wait for a second or two before shutting itself down and stopping the stream in that period
which stream
I have no control on that
client.attachContainerCmd
The frame adapter has a onStart method
And this is passed a closable which will close the underlying streams and streamer thread when invoked (using interrupts)
So you can gracefully exit the stdin/stdout/stderr streaming
@timber mirage you could try client.removeContainerCmd(containerId).exec();
sorry
maybe not
The problem is that the remote end disappears
what's the inverse for attachContainerCmd?
And the only way to stop that is
Calling the closable you get in onStart when attaching
but why would this be a problem
are you saying that in the common case where the container would stop for any reason, it will caus this error
this isn't normal
You are streaming logs by opening a tcp connection to the docker daemon and you try to read from it
At some point the container says bye
And then the question is where in the protocol your client is stuck currently
Judging by the code in FramedInputStreamConsumer at least
@timber mirage try this:
It should signal closure
client.attachContainerCmd(containerId)
.withLogs(true)
.withFollowStream(true)
.withStdOut(true)
.withStdErr(true)
.withStdIn(stdin)
.exec(new ResultCallback.Adapter<>() {
@Override
public void onNext(Frame object) {
try {
String payloadString =
new String(object.getPayload(), StandardCharsets.UTF_8);
if (object.getStreamType() == StreamType.STDOUT) {
pipeOut.write(object.getPayload());
} else {
LOGGER.warn("Received STDERR from container {}: {}", containerId,
payloadString);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
@Override
public void onComplete() {
try {
pipeOut.close();
LOGGER.info("Stream from container {} closed successfully.", containerId);
} catch (IOException e) {
LOGGER.error("IOException while closing stream from container {}: {}", containerId, e.getMessage());
}
}
});
added public void onComplete() { to the block
On my machine you eventually receive an EOF in step 1
And then it gracefully shuts down
so what happens in my case ?
why do you not get this error ?
and also
I wish to know
Why I never got this problem before ?
environmental?
did you download a fortnite vbuck generator recently or something?
or maybe a windows update?
no
java version?
But it takes a while for the docker container to exit after the evaluation
are you using his branch @ebon river ?
enhancement/improveclose
there were some changes made to the close functionality, instead we first mark is as "dead" controlled by a boolean and then there's a scheduled task to remove them
so why is this a problem only for me ?
how am i even supposed to find such answer
Add the logging breakpoint there maybe and see what you get
and how it correlates to the containers dying
wdym
wdym
What do you mean?
What do you want me to do ?
at this point, you might have better chances in #1051826284008853505
This is the data of the stream when it crashed
ah
well
it got rid of the null characters
but imagine that there are null chars before the OK and a ton of null chars after the last line
@sterile crest @ebon river
how did you run it ?
I tried to run the api from inside docker
and I don't get the error
try {
writer.close();
} finally {
reader.close();
try {
reader.close();
} finally {
if(!dockerService.isDead(containerName())) {
dockerService.killContainerByName(containerName());
}
}
}
while I get what you're trying to do...
it flipping sucks
Do you have a better idea ?
try {
writer.close();
} catch(Exception e) {
LOGGER.error("Failed to close writer", e);
}
try {
reader.close();
} catch(Exception e) {
LOGGER.error("Failed to close reader", e);
}
if(!dockerService.isDead(containerName())) {
dockerService.killContainerByName(containerName());
}```
It's more redondant 🙂
yours is redundant
and worse
here's why
reader.close(); being called twice
that's redundant
wait
if one fails, you don't know which one - less observability
that's a typo
try {
writer.close();
} finally {
try {
reader.close();
} finally {
if(!dockerService.isDead(containerName())) {
dockerService.killContainerByName(containerName());
}
}
}
should have been this
anyway
I'll fix it
you're dong all this unnecessary try-finally nesting
but then again
your code is never readable so idc 😄
jshell is such a toy
public void close() {
try {
writer.close();
} catch (Exception ex) {
LOGGER.error("Unexpected error while closing.", ex);
}
try {
reader.close();
} catch (Exception ex) {
LOGGER.error("Unexpected error while closing.", ex);
}
try {
if(!dockerService.isDead(containerName())) {
dockerService.killContainerByName(containerName());
}
} catch (Exception ex) {
LOGGER.error("Unexpected error while closing.", ex);
}
LOGGER.info("Session {} died.", id);
}
alright
is it more readable tho 🤔
yes but your ordering of logging is wrong
LOGGER.info("Session {} died.", id); needs to go after if(!dockerService.isDead(containerName())) {
it is ?
yes because LOGGER.info("Session {} died.", id); will log even on failures
also @sterile crest ?
weird
it working on docker means it's purely environmental when running locally :p
then change the message
?
imagine seeing Session died in the log message
but all the code to kill the session exception
the session didn't die
then you would see the error just before
not if you're filtering by info messages
who would filter out errors ?
people who work on production systems and actually monitor logs using proper tool
no
it's not common practice to look at log messages in the console or just as a .txt file
you need more profesional experience in software development
if you see:
error
error
error
session died
okay errors idc about now because "session died"
but the session didn't die
but your logging told me the session died
your close method isn't killing a session then
your logging in the wrong area of the code
it is
give this example
public void close() {
LOGGER.info("Session {} died.", id);
}````
this is what your code is doing
if we ignore the errors
yeah 🙂
Alright, pushed
gradle spotlessApply
if(shouldDie()) throw new DockerException("Session %s is already dead.".formatted(id)); don't forget braces
and the error message should be different because the session is not dead explictly
hmm
} catch (Exception ex) {
LOGGER.error("Unexpected error while closing.", ex);
}
try {
reader.close();
} catch (Exception ex) {
LOGGER.error("Unexpected error while closing.", ex);
}
more complicated than that
put "Reader" and "Writer" in the messages for clarity
shouldDie -> session at least half dead
yeah
"Session is no longer available because it's either dead or marked for removal"?
shouldDie -> at least irrecoverable, maybe totally dead
markAsDead -> has been marked for next heartbeat
nah
like I said
the problem isn't this message here
since it is true
ok
the problem is here in those names
but I could find anything better
if(service.isMarkedAsDead()) {
try {
jshellSessions.remove(id).close();
LOGGER.info("Session {} died.", id);
} catch (Exception ex) {
LOGGER.error("Unexpected exception for session {}", id, ex);
}
} else {
service.markAsDead();
}
redunant else
session is already marked as dead
ah yeah myb
Maybe this should be renamed: LOGGER.info("Session {} died.", id); to "Session has been removed"
actually
nevermind
its correct
forgot it's doing a close() too
public void deleteSession(String id) {
jshellSessions.get(id).markAsDead();
}
can we remove this and just use jshellSessions.get(id).markAsDead();
since it does the same thing
deleteSession != markAsDead
since it is called by several places, no
refactor the name?
I will take a pause
ok
Can you move to the pr and do an actual review please
instead of talking here
it will be lost
that's the last comment
damn, brutal :(
what ?
He just has an emotional attachment to docker sessions @timber mirage
I killed so many of them
should is a moral judgement, something that ought to be, compared to somhing that just is
it's like saying container deserves to die :(
you wish death upon it
but it is already dead
which is arguably worse than just killing it in self-defense
ah, should be dead, not should be killed 👌
No wonder we're having issues with containers dying
And the VPS not being cleaned up
Technology has feelings too
The TogetherJava VPS is supposed to be like heaven for tech, a nice safe place for them to live without the fear of dying
Now it's a graveyard of docker sessions 😦
Well it's not a graveyard since there is no tombstone to count the history of dead containers, more like a crematorium
We should be kind to our software, let's leave the containers running but they all can host their mini web servers and we can use spring to load balance
Actually, we should have done that
Sounds like hell
They must burn!!
anyway #chit-chat
yoo
sorry for being late I had a time issue today while checking-out from hotel .. anyway
is it solved ?
no
nope, you got any ideas?
alright, based on the discussion above
it looks that alathreon is only one having the issue
without knowing yet how it happens
well spotted
that means, ala has something causing the issue
it would be useful if somebody having a no issue version, to assist ala via a tool like rdp
excellent idea, any tools you recommend? maybe you can rdp onto his machine and investigate
i mean to reinstall whole app
ye why not
but not today, as i dnt have much time
i m still checking the changes and learning about docker api
gotta sleep early too
I keep getting these logs without doing anything yet
2024-08-05T22:20:09.172+01:00 INFO 21452 --- [pool-2-thread-1] o.t.j.service.JShellSessionService : Scheduler heartbeat: started.
2024-08-05T22:20:09.173+01:00 INFO 21452 --- [pool-2-thread-1] o.t.j.service.JShellSessionService : Scheduler heartbeat: sessions ready to die: []
2024-08-05T22:21:09.158+01:00 INFO 21452 --- [pool-2-thread-1] o.t.j.service.JShellSessionService : Scheduler heartbeat: started.
2024-08-05T22:21:09.158+01:00 INFO 21452 --- [pool-2-thread-1] o.t.j.service.JShellSessionService : Scheduler heartbeat: sessions ready to die: []
is this normal ?
we all should be ready to die
I think sessions just adopted philosophy of the great Stoics
so looks pretty normal to me
they don't seem depressive or suicidal, just mentally built different, strong 
not scared of the future, calm and ready
logs are more detailed, to help you with debugging 
you can pick and choose the log level to your liking
the level is info and those logs are infos
it would better to switch them to debug lvl
JShellSessionService looks too complex ngl
alright, it seems that im gonna be stuck with the current code base
as there are no comments, in addition to some ugly stuff
in fact alathreon is not the only one who notice the errors
i had some errors too, and they're mysteriously gone
as this is 1st time i try such project, i think it'd be better for me to exercice a bit
so i'm gonna try a sample with similar objectives, but in minimal shape
will come back with updates
if you can reproduce the issues, you can go trough it with a debugger
that way you can see what is happening and you can follow the flow
the problem is
i'm unable to understand the current codebase
it's too new to me, or maybe some parts are ugly
yeah, it's somewhat complex
spaghetti code
what do you feel is lacking?
you can ask ala for explanation of parts that are confusing
try to follow the flow of the command with debugger
that will not help as i may re-ask anytime
i think that's why
not many people came
it lacks clarity
opensource project without documentation is like private
im gonna build a very basic sample that works properly
after that i may come again
Yes, it's the session killer, each X time, it will check for alive sessions, that's called a heartbeat
A ton of reason, many software have things that run in the background
Do you have any idea about how to simplify it ?
Like ?
alright, i dnt need it
actually it confuses me
Most of it should be obvious, there are doc for methods whose behavior isn't obvious, but most of the time, it should be fine
wdym
why ?
after i created a session
i expect it to be in the list to die
but the logs keeps saying
sessions ready to die []
wdym
yes, so there are no session ready to die
hows that ?
the session is up
yes
and ready to die
nope
sessions have a lifetime of 30min by default
after those 30 minutes, they will die
ye but it could die earlier
well no
the idea is to keep the session alive, so the user could use the previous statements and add new ones
or also read their own statements
So you could sent a request which contains a class
this is not mentioned
anywher
and then a request to execute code using this class
as i said earlier some parts are hard to read (complex)
and i dun't know how to simplify them
(it's not up to date but at least the general idea still works)
im still learning
show me those parts
ahaa !
I mean this https://github.com/Together-Java/JShellPlaygroundBackend/blob/develop/JShellAPI/README.MD
Remember, it's no up to date, but at least the general idea is still here
jshellsessionservice
anyway, np
im gonna exercice with a minimal sample
i need to do tht
which part ?
I advise you to just look at the public methods
like
collapse everything
and look at it like you would look at an interface
only see public
and even ignore bodies
i advise you to follow the command with debugger, and see how it works, the flow
should help a lot
to get the familiarty and see how the systems fits together
You shouldn't even this this, you could follow it with your eyes, since there are nearly no interfaces so no indirection
debugger offers a lot of cool tools
i know i can do it
and you get annotated values
well yea, a debugger would make it even easier
so it's easier to follow and play with the codebase
i knooow
but yeah, whatever you are more comfy with
🤷
Firas struggling to read code??

He's one of our top expert members too, so there must be really deep rooted problems
stop making fun of me will u?

i'm just playing, not making fun of you, you're right about some of the observations
Today gonna full debug
my 1st lesson in tj-jshell
As for the future it would be nice to create a website for it

A playground with file explorer would be great
We have a discord bot where you can use jshell command 🙂
I know tht already
But what if we think about extension?
It would be cool, like codesandbox
It's in same context ig
Well yes, that's one of the reason why I created a REST API at the first place
i think about writing a schema.json openapi for the api
without need to the springboot openapi dependency
thus, the controller's code can rest without additional annotations
the schema can be used in swagger ui playground
someone already did that iirc, but ala disliked it, check PRs
I want to reduce the number of annotations, it's fine if there are little of them
ah, without annotations
yes
There might be ways
Like create an interface with swagger annotations
so it's splitted between the code and swagger
my approach is to split schema from from java code
but it must be something to validate
so maybe yes
So if you wan't, you can study this idea
I don't think so
we need to set that up
also sonar and other tooling
sonar will probably raise a lot of issues that would need to be addressed
we don't need an openapi spec right now
the focus should be purely on the functional aspects, like making sure it works
I meant it's not priority
It just came to my mind and wanted to share
rebase from develop yes, like tj bot
oh boy
so session are kept in memory
private final Map<String, JShellService> jshellSessions = new HashMap<>();
i dnt get this
jShellService is a spring bean
it's the 1st time i see this
ah JShellService refers to session?
the name is ambiguous
is it ok to write some comments and rename some methods to make names have more sense ?
another question: why there are no entities ?!
alright im going to make some changes in a separate branch
and PR
good question
what do you think about architecture and layering?
kinda spaghetti
more vertical or horizontal
maybe we should do domain driven development with hexagonal architecture?
how would you do it?
oh nice
or standard model service repository or whatever
right, we can just use json config
wdym by that?
what about an inmemory database?
if bot dies, all sessions are lost
possible as enhancement
or when we deploy new version
the current impl can work without db ig
if api is down
right
if persistence is a requirement
then we should add orm, db and entities
maybe containers would infiniteky accumukate, because they wouldn't be kilked
however, id add entities package even without db
cache tool
ah i heard about it
never used it
id go to firebase
it gives lota options
Redis would be nice, especially if u are just using it for caching.
oh it's not free
maybe we can use neo4j
it's a graph based db
it's the best performing graph db and it's also java based
it supports generative AI now
we can replace the HashMap with this
that's a problem
free means it's not gonna be good
self hosted 
ah as a container
that depends on @compact holly
alright, we're getting faraway from objectives
we'll get back to this as soon as we fix the current version of the app
what happened to it? Did it crash or smth
depends on all the good people of tj that help maintain the infrasturcture
you will se those have the VpsAccess role 
ye, that's a good thing to focus on
what is the current issue you are having?
make an issue
because there is no db
What do you mean
It's controller -> session service -> jshell service -> docker service
Yes, I don't see a point of persisting something that will disapear within 30min anyway
Nah
We can do that in tj bot side
Well
not if we have firas idea of multiple consumers
yes indeed
anyways that's all free with AWS 
the idea you originally thought was stupid btw
"why we have this API, we don't need it blah blah"
you simply did not see the bigger picture firas did
me*
we will have a magnificent website where people could run their code on
and maybe even embed our code runner to their sites
that will promote our community
and create backlinks
the problem with an API is that there's additional latency and overhead
ah, the performance
Problem is that the server is too weak to handle this
like Kafka
we can't spare 3ms of latency 
it's more than that
you can't scale the API with the current infra
we will host that on wazei's aws
he claims its free 
see
...it won't work like that
millions of daily users for free
but yes, imagine every technical blog having our code runner exampels embedded
the free tier is in the hope that the business gets thousands of users
togetherjava will become intergalactically famous and respected
then they can bill you properly
for TJ and small businesses, it's perfectly fine
i can even make a serverless discord bot
the thing that keeps a discord bot showing as "online" is the heartbeat, you can use AWS EventBridge scheduler for that
and use AWS APIGW Authorizer for serverless web socket events
or use EventBridge to wake up when it receives an event
we are broke, it's impossible to bill us 
we declare bankrupcy, and whoop, it's gone 
our usage is so small anyway
that's how dept works in us at least
yeah, but you are not imagining the world firas does
in firas world, we are large and respected organizaton
we have a website where you can run code with our jshell api
and my idea is to make it embeddable in every website, or tool that needs to run code
so every blog uses our tech, stackoverflow answer
to we become internationally famous
well if we used my original "just give the user an entire linux container"
then we have unlimited possibilites
firas world is big picture world
well if it work in web, it works on phones as well
we can get my guys to create an app using jetpack compose and it'll let people run our jshell service too
we can scam people with some electron bs
hello?? jhtmlbridge??
right, some people would ask who runs java code on their phone
and our answer should whoever wants
we did it because we could, to prove our technical superiority
We can build our API using https://github.com/surajkumar/wazei
the wazei web framework
riight, all wazei stack
exactlyyyy
public class HelloController {
/**
* ---
* $method=get
* $path=/hello
* $content-type=application/text
* ---
*/
public String hello(String nameParam) {
return "Hello, %s!".formatted(nameParam);
}
}
look at that
your comments control logic
anyway, once we host brian goetz here on the server
or if you dont like commenting your code
public class HelloController {
public String greet(String name) {
return "Hello, %s!".formatted(nameParam);
}
}```
we can help him make project loom and panama happen
i have no doubts :D
: D : D
@compact holly we can even use the wazei concurency library: https://github.com/surajkumar/concurrency-library
riight
it comes with built in monitoring and metric collection
System.out.println(promise.getMetrics()); // To get metrics of a Promise
// > PromiseMetrics{start=140720275666100, end=140720275677900, success=true, executionTime=11800, memoryUsage=0, errorDetails='', stackTrace=[]}
are these actually real links?
you created random projects to spice up your CV?
soon you will have more libs than ethan lol
ah, more sphisticated
but at least I'm not just repackaging existing libs
u should see my private repo's
like this one
rather not
u can test an API using Socks5 proxy
so when we wanna simulate real users
i gotchu
This repository contains 290 open Socks5 servers that are available for use.
/*
* Call our example REST API call 10 times for each proxy.
* Since there are 290 registered proxies, all 290 servers will run our request
* 10 times sequentially.
*/
socks5.run(10, exampleSocks5);
oh, expected something like: https://github.com/Deepshift/DeepCreamPy
in your privte repos
was cutting edge AI tech at it's time
is that your project as well?
incredible
i also made this "route to mic" feature which lets you pipe the audio from azure voice to in game chat
great for those people shy to talk but still wanna use ingame coms
how many stars does that project have?
do you have any uwu intellij extensions?
you know, moral support while you write code
someone to cheer you on when our shit finally compiles
i actually replaced all my icons with ur profile pic
ty, i needed an icon change
maybe enable partial compilation
i made u my start icon
so you can compile justone method
and run it
and not having to build whole ass thing
for quick testing and protyping on larger projects
marko u like anime stuff right?
our jshell will make a revolution in the industry
uh.. kinda creepy, hopefully not sexual
but evne if it's sexual, at least you are happy 
if you send a message e.g. -hug- @wazei - it'll send an embed with an anime hugging gif saying "marko hugged wazei"
why would I buy if you just sent me the codes, dummy 
never thought hacking would be this easy
jesus christ 
you can't compile 😄
JDA no java discord api!/
its old code
smh
any code*
i can teach u how to use azure voice once firas does his azure migration
anyways
enough shit posting
that would have to be a premium feature
why are we swithing to azure not alibidbaba
broo has anybody uses the cloud stuff alibaba has?
weebs are easy target to get some monies
I acually wanna try it, I thought its more popular than gcp
gcp kinda sucks ass
my cloud journey started gcp>azure>aws
the ui sucks
i never was happy with gcp, back when i was a google fan boy, i did my best to love their products
but gcp was aids
what if a meteor hits ur server?
then it would hit me too, so I wouldn't care 
okay ill ask firas to put that down as part of our risk mitigation diagram
i think the idea was to run a really long USB cable from your house to his?
actually, it's possible if we become tier 1 ISP
or tier 3 can't remember which one digs up the ground and lays cable s
ye, it's easy to be ISP
people done it locally, because monopolies
basically fancy wifi
i looked into doing it before but it wasn't cost effective
and you can have 10gbit/s connections
you can't
it's not some shitty tech
usb is not similar to ethernet
it wasn't my idea
"his"
sorry ala
we're off topic
@compact holly @sterile crest please I am tired, stop going offtopic here
so what's the topic on jshell ala?
?
so this thin
is there something u wanna talk about around jshel?
you can just shoot internet to pepople trough air
and they can have 1 or 10gbit
no issues
it's cheaper to set up, because you don't need to dig up the infra
but more expansive over the long run
but how would u get 10gig
these are powerful
connected to what host?
not same wifi crap tech
u still need a physical 10gig somewhere
not really ?
????
i mean yeah
but no digging the whole city
you shoot internet from one place to the user
but i live in the UK
well from many places
ah, that sucks
so from my house we need a long cable leaving our island?
just dig a hole through the middle of the UK 😄
i pay $10 for gigabit
10gig would be maybe $20, dunno
shit's cheap
multiple fiber providers in my building, so strong competition
actually 1 isp called me 10 today
so aggressive, offering me 250mbit and iptv for free
for 2 yeras
in the hope that I will stay with them afterwards or something
I was thinking to maybe have another network with servers with that connection
but can't be bothered with all that bs
it's free tho :/
could be used for good
anyway, this doesn't help us with jshell
@bright lark, what's your progress
update us
simple solution would be to not live on the island
not that u could afford it
having to do cabling through ocean is pain in the ass
poor austrailans get triple fucked
they have 300 ping in most games, ozon holes give them cancer
they live upside down, and the wildlife is very hostile
living life on nightmare diffuculty
hi again
i don't know why u enjoy talking about offtopic here
ive done some debugging to understand the flow of the app. I ve tried the /jshel/eval/{id}
the docs helped me to get closer
however, i notice some weird patterns
like injecting docker and session services into the model JShellService
this could lead to errors or circular deps
also some method names look ambiguous. some conditions are duplicated unnecessarily
it seems that the project was created quickly without thinking too much about maintainability
JShellService constructor takes 12 args !
as i said previously, the hard part is thinking, code is the easiest part
so i may add some diagrams to show the actors, uc and flows
no! it's just tht i dun't want to talk about this rn
i dn't have any, im just inspecting the current codebase in develop branch
gotit
There is a plan to remove session service from here which would solve this problem
like ?
I was fixing this last day, there will be a pr soon
is there an issue for it ?
like session()
no, but it will naturally go away
duplicated condition
if (!hasSession(id)) { }
wdym
a method name must indicate a behavior. session doesn't seem clear
oneTimeSession() too
as for createSession() it looks fine
right, we will rename it to fetchSession
It's actually addOrUpdate or somthing like tht
or get
too complex for a name
Idnt think so, it looks clear
The method adds a session or update an existing one
Maybe a more clear name is createOrReuse()
Also session id should be provided by the system
Not by client
So if id is null, tht means NEW, if it's not null, it means reuse/update
the exact name should be createAndGetOrFindAndGet
That's a no
Lmao
What do u suggest then?
Maybe we should split them
Into 2 endpoints
POST/session and PUT/session
no
sessions should automatically be created
And
fetchSession is a correct name
how would I fetch something that doesn't exist yet ?
the name confuses reader
im typically creating a session, so method must be create() or add()
while when i fetch an existing one, i may use something else like fetch() or get()
🤷♂️
You can't just make everything more complex because you can't find a name
You don't need to know that, it's abstracted away
alright, we can keep /eval
but we should change the name of session()
createOrFetch
how's tht?
And even then, it is included in the word fetch
You can see it as implementation detail
imo we need to have 2 methods in JShellSessionService
and call right one based on the args
if(newId){
return create();
}
return fetch();
also, im not certain that providing id from client is ok
You just reinvented session()
How is it redundant?
Then call it find
Which condition?
i mean this if (hasSession(sessionInfo.id())) {}
Sorry I don't have the code under my eyes
Alternatively you could call it obtainSession
public JShellService session(String id, @Nullable StartupScriptId startupScriptId) throws DockerException {
if (!hasSession(id)) {
return createSession(new SessionInfo(id, true, startupScriptId, false, config));
}
return jshellSessions.get(id);
}
Right, and createSession?
private synchronized JShellService createSession(SessionInfo sessionInfo) throws DockerException {
// Just in case race condition happens just before createSession
if (hasSession(sessionInfo.id())) { }
}
even the comment is not signficant
i dnt recall
i think yetserday when i tried it
for my 1st session, it was false
Wdym you don't recall? Do you not remember the code, do you not have the code under your eyes?
?
Please show the code
i did
No you didn't
there is a collision between session() and createSession()
You cut the part I asked
Please show the code
private synchronized JShellService createSession(SessionInfo sessionInfo)
throws DockerException {
// Just in case race condition happens just before createSession
if (hasSession(sessionInfo.id())) {
return jshellSessions.get(sessionInfo.id());
}
if (jshellSessions.size() >= config.maxAliveSessions()) {
throw new ResponseStatusException(HttpStatus.TOO_MANY_REQUESTS,
"Too many sessions, try again later :(.");
}
LOGGER.info("Creating session : {}.", sessionInfo);
JShellService service = new JShellService(dockerService, this, sessionInfo.id(),
sessionInfo.sessionTimeout(), sessionInfo.renewable(), sessionInfo.evalTimeout(),
sessionInfo.evalTimeoutValidationLeeway(), sessionInfo.sysOutCharLimit(),
config.dockerMaxRamMegaBytes(), config.dockerCPUsUsage(), config.dockerCPUSetCPUs(),
startupScriptsService.get(sessionInfo.startupScriptId()));
jshellSessions.put(sessionInfo.id(), service);
return service;
}
public JShellService session(String id, @Nullable StartupScriptId startupScriptId)
throws DockerException {
if (!hasSession(id)) {
return createSession(new SessionInfo(id, true, startupScriptId, false, config));
}
return jshellSessions.get(id);
}
public JShellService session(@Nullable StartupScriptId startupScriptId) throws DockerException {
return createSession(new SessionInfo(UUID.randomUUID().toString(), false, startupScriptId,
false, config));
}
session() has 2 versions
Ah I see
Yes it's to avoid a race condition
Alternative would be to extract this if into session and add an additional sync block here
Well you could also do that, it's just that it will always reach a sync block
Which while it could backfire if we increase the size of this by a lot, it shouldn't matter right now
wdym
There is a chance two threads arrive on the if in session at the same and so try to create a session for same id
alright, why we have session() if it's only to call createSession() ?
let's get rid of session() then
The problem that I had is that it is syncronized and so it doesn't scale well
wdym
do you know what syncrhonized do ?
what i know is that it's for thread safety
which means the method cannot have multiple threads on it at a time
so i dnt get what u mean by
it is syncronized and so it doesn't scale well
btw i think that createSession is an async operation as it waits a response from docker
Yes, so if two requests arrive at the same time, and ession was sync, then the requests would be evaluated one at a time, whicle while it currently works scale vary badly, because the more requests we have, the more problems it will cause
how about using @Async
How will this solve anything ?
i dunno 
Ah and because of makro and wazei oftopic, I can't find what they said last time
@sterile crest can your review my pr please ?
ive read tht @Async in spring is helpful to assert one thread handles async operation
is tht unrelevant
no
are u able to force merge ur PRs @timber mirage ?
ah okay
I am waiting for a review
join what ?
in pr
Do a review if you want
what ?
We were talking about my pr
u have more than one
about revewing my pr
im checking this one https://github.com/Together-Java/JShellPlaygroundBackend/issues/44
im still debugging (learning)
as i said previously, there are some weird stuff
and i gave examples
tests could be done when there is clean stable codebase
?



