SMB jcifs "jcifs.smb.client.dfs.disabled=true" impacts - java

I had a performance issue with SMB file upload using JCIFS SMB. The problem was related to jcifs.smb.client.dfs.disabled property and using true fixed the issue.
Now the question is that in which case I will be having problems using jcifs.smb.client.dfs.disabled=true as it has to be static property for me? I have many different environments which is using the same configuration.
Properties document (link) says:
If this property is true, domain based DFS referrals will be disabled.
The default value is false. This property can be important in
non-domain environments where domain-based DFS referrals that normally
run when JCIFS first tries to resolve a path would timeout causing a
long startup delay (e.g. running JCIFS only on the local machine
without a network like on a laptop).
... but this is over my head, cannot understand.
Also, if I could change that dynamically, what is the indication that I need to do that? Any specific Exception or scenario that points out that true or false is needed?
Thanks!

Please read this - what is DFS.
In general you can mount your folder to a different share.
For example PC1 has Share1 and the PC2 Share2 had a folder named "not located here" and it points to PC1 Share1 (just a link).
To resolve the real location The SMB uses an IOCL query "get_referrals" and this is the implementation of the DFS.

Related

Java program is unable to write on mounted system in linux

I am currently working a scenario where we have to create a file in a shared directory in Linux as well as Windows.
I have gone through the following link to achieve it :
https://www.journaldev.com/878/java-write-to-file
https://it.toolbox.com/question/how-to-write-a-file-in-a-network-folder-without-using-ftp-031208
I was able to achieve it in windows network like giving the file name as (\\198.168.1.1\data\files)
But for the Linux first I used NFS to share a particular directory using below links :
https://alvinsim.wordpress.com/2012/06/21/mounting-nfs-from-linux-to-aix/
https://www.tecmint.com/how-to-setup-nfs-server-in-linux/
But got the following exception :
java.io.FileNotFoundException: /data/files (Read-only file system)
I found the following issue resolved in following thread, but I could not succeed :
https://askubuntu.com/questions/197459/how-to-fix-sudo-unable-to-open-read-only-file-system
Any advice is appreciated.
So finally I was able to figure what the problem was.
The entry which I made as per link in /etc/exports file is not sufficient.
We would need to use some options as well like (sync,rw,etc..) for allowing any manual modifications or modifications using any java program.
In my case, I should have used the options (rw,no_root_squash).
And it worked.
As very well explained in :
https://serverfault.com/questions/611007/unable-to-write-to-mount-point-nfs-server-getting-permission-denied/611013#611013?newreg=ce76e9417ca645da9487a5d9ccbf0371
From Docs on :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/s1-nfs-server-config-exports
root_squash — Prevents root users connected remotely from having root privileges and assigns them the user ID for the user nfsnobody. This effectively "squashes" the power of the remote root user to the lowest local user, preventing unauthorized alteration of files on the remote server. Alternatively, the no_root_squash option turns off root squashing. To squash every remote user, including root, use the all_squash option.

acessing the Sonarqube with http://xyz.abc.com:9000

We are working in project where we wanted to customized the rule. To customized the rule, we need to upload a file to sonar server. As we are working in a restricted environment where we can't upload the file to unknown server. We can only upload the file only if server url end with abc.com.
is there any way to change the url http://localhost:9000 to http://xyz.abc.com:9000..??
Your question is completely independent from SonarQube as it boils down to hostname management, mapping xyz.abc.com to localhost (and/or to SonarQube server's IP). Changing sonar.web.host (as per your above comment) won't help at all as it is for SonarQube to bind on a specific interface, something unrelated to your situation here.
Approach your problem from a network connectivity (and name resolution) perspective. Your goal can be summed up in: xyz.abc.com must resolve to the IP of the server which hosts SonarQube.
If all work is only done locally for now then per comment from #snakecharmerb you can update your /etc/hosts with a new mapping, otherwise update your DNS with a new entry.

Horizontal Clustering using HazelCast

I am using hazelCast-3.0 jars . I am able to create vertical cluster(on the same System where only port no. differ from one server to other Ip remains the same.) and its working pretty good.But i want to create horizontal cluster(where i can use any ip address along with any port no. depending on the configuration). If this is possible in hazelCast then please share how. i went through several links like http://www.hazelcast.com/docs/1.9.4/manual/multi_html/ch11.html
if this link is useful the suggest me how. I made only change to hazelcast.xml.
<tcp-ip enabled="true">
<hostname>172.22.65.111</hostname>
<hostname>172.22.68.19</hostname>
<interface>172.22.*.*</interface>
</tcp-ip>
On both the system same jar file are being used.It i create a map name "xyz" and store some value to it .Then it should be available to other system with same map name "xyz".
here is the code that I am using on my system
clientConfig.addAddress("172.22.65.111:5701");
System.out.println("p2");
HazelcastInstance client = HazelcastClient
.newHazelcastClient(clientConfig);
IMap<Integer, String> map = client.getMap("m");
map.put(1,"ram");
Same code is on the second system also except ip and port. And insteed of put i am trying to get on the other system.
your link refers to an outdated Version of the Manual.
If you follow the getting started guide at
http://www.hazelcast.com/docs/3.0/manual/single_html/#GettingStarted
you should be able to form a horizontal cluster by starting the sample code on two separate machines.
The current hazelcast distribution also contains a bin folder with sample applications.
I find a new in memory grid based on hazelcast 3.0 clone-griddatamaster.(griddatamaster.wordpress.com) They claim they will provide enterprise class future like security,management console...and some cool futures from gigaspace and oracle coherence
griddatamaster.wordpress.com

Checking if application is already running

I have a Java Application that uses JPA on a file DB.
I want only one instance of my application running (Note that the DB gets locked to the first instance of the application).
How could I check if my DB is locked or not, and present a message to the user?
Telnet your DB with its ip and the port number.
Eclipse solve this solution with a .lock file. Other solution can be: try to use a port: bind to port 12345. If you can than you are the only one king of the hill if you can't, than maybe other are using that hill. Any other apps can.
The .lock file has many disadvantages too.
And the last and best solution is: do it with platform dependent at way at OS level via JNI, but require a lot of work and has disadvantages too.

Running Local Java Application with File System & Port restrictions

I need to run a java application (not an applet or JNLP, but a full blown application in the JRE) and need some restrictions on:
File System - The app could only access 1 folder to read & write (this would be a fixed path for the app's reference like / )
Ports - The app could only access several local ports. (eg could only access port 8080 / 3306 only)
Is there a way to do this? I have searched through Java Security & Policies but came nothing close to a solution.
I am considering to write a container to run this app or changing / overriding the classes (in case of OpenJDK). Is this ok?
This is for an open source project that we are about to start, Appreciate some good advice from the wise StackExchange community.
regards
First and most basic, run the java application with a user who has the minimum permissions required for the app to do its work.
Secondly, set the java SecurityManager and configure it.
SJuan76 has the right answer here. The SecurityManager is the appropriate way to restrict files/directories a java app can access. This tutorial might be a good guide to setting that up.
You can restrict the ports your java app listens on. But restricting ports really requires an OS level firewall to be configured.

Categories