saxenasaral
BAN USER
- 0of 0 votes
AnswersWell design a master controller/scheduler which should be configurable and capable of running multiple processors at a same time
- saxenasaral in India
Scheduler Operation :-
scheduler process should be able to perform various operations below are the examples
1. execute sql queries and stored procedures in the database
2 should be able to send emails with given set of arguments and attachment to business
3 should be able to send ftp files based on input arguments
4 should be able to execute batch files
process should have below capabilities
Process Operation :-
1 Remotely start/stop a child process
2 Raise alerts when any above process fails
3 Automatically restart the process if it fails
4Remotely kill a child process that breaches a pre set timeout limit
so for scheduler and processor I have to come to design with
1 High level design
2 Class level diagram
3 Design should be flexible t incorporate more operations
4 any design pattern you think we can use| Report Duplicate | Flag | PURGE
Adobe Analyst
1) You can set a global handler by calling the static method Thread.setUncaughtExceptionHandler, or
2) You can set a thread-specific handler by calling setUncaughtExceptionHandler on the individual thread, or
3) If you are in a thread group, you can override ThreadGroup.uncaughtException() method (ThreadGroup implements the UncaughtExceptionHandler interface
below is the sample program also ..
import java.lang.*;
public class ThreadDemo {
public static void main(String[] args) {
Thread t = new Thread(new adminThread());
t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
System.out.println(t + " throws exception: " + e);
}
});
// this will call run() function
t.start();
}
}
class adminThread implements Runnable {
public void run() {
throw new RuntimeException();
}
}
this will produce the following result:
Thread[Thread-0,5,main] throws exception: java.lang.RuntimeException
That seems the most effective way using Java....
*****************************************************
String[] a = {"a","b","c","d"};
String[] b = {"b", "c"};
Set<String> set = new HashSet<>(Arrays.asList(a));
set.removeAll(Arrays.asList(b));
return set;
Singleton bean in Spring and Singleton pattern is quite different. Singleton pattern says that one and only one instance of a particular class will ever be created per classloader.
The scope of Spring singleton is described as per container per bean. It is the scope of bean definition to a single object instance per Spring IoC container. The default scope in Spring in Singleton.
A Singleton candidate must satisfy three requirements :-
1) Controls concurrent access to a shared resource.
2) Access to the resource will be requested from multiple, disparate parts of the system.
3) There can be only one object.
lem me add few things in it in terms if you are implementing the same thing with context to servlet..
The servlet container should automatically redirect the user to the HTTPS listener if you set the transport-guarantee element to CONFIDENTIAL or INTEGRAL in your web.xml, like so:
<security-constraint>
<web-resource-collection>
<url-pattern>*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
lem me add few things..
List is an ordered sequence of elements whereas Set is a distinct list of elements which is unordered
List<E>: -
An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
Set<E>:
A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.
╔═══════════════════╦══════════════════════╦═════════════════════════════╗
║ ║ List ║ Set ║
╠═══════════════════╬══════════════════════╬═════════════════════════════╣
║ Duplicates ║ YES ║ NO ║
╠═══════════════════╬══════════════════════╬═════════════════════════════╣
║ Order ║ ORDERED ║ DEPENDS ON IMPLEMENTATION ║
╠═══════════════════╬══════════════════════╬═════════════════════════════╣
║ Positional Access ║ YES ║ NO ║
╚═══════════════════╩══════════════════════╩═════════════════════════════╝
Regarding inserting elements :-
This class implements the Set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the null element.
The insertion order directly influences the iteration order whenever you have a bucket collision:
When two elements end up in the same bucket, the first one that was inserted will also be the first one returned during iteration, at least if the implementation of collision handling and iteration is straightforward (and the one in Sun's java.util.HashMap is)
Repmakaylamelua, Blockchain Developer at AMD
I am a sound editing and music composer with experience of handling a wide variety of programs.During my free ...
RepI am Susan From Wasilla USA. and my strong interest in yoga and reading historical books. I have a large ...
Actually out is a static member in the System class , being an instance of PrintStream. And println is a normal (overloaded) method of the PrintStream class...
- saxenasaral September 09, 2014