Distributed data structures in Java [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm going to develop my own message queue implementation in Java and I need to distribute the queue content across multiple servers so that it would provide reliability and redundancy.
In addition to that I need to persist the queue content into the file system.
Can somebody tell me what is the most suitable distributed data structure implementation to hold my queue content?
Note: That data structure must provide me the message ordering facility. That means I need to receive messages according to the order they arrived. Also while reading a message, it should be in a 'locked' state so that other consumers cant read it until the first consumer completes the reading process

Have you looked at any of the many existing message queue implementations for java? Wikipedia lists many open source implementations. It seems to me that an existing, thoroughly tested message queue is the best place to hold your queue content :)
If you absolutely want to write your own, then starting with the open source solution that most fits your needs would probably answer most of your questions about what data structures work well.

Related

which database for java to store data in memory? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm looking for a database which would allow me to store most of the objects in the memory. Basically I want to store in the memory everything except some rarely used data (history of changes, etc).
I'm looking for:
simple API for java, preferably non-ORM
ACID is not required (well, D is)
some support for queries, but nothing fancy
The idea is to operate on a model in memory, store any "command" mutating the model in the database, periodically synchronize model to database (like prevayler does)
Which database matches my needs? (I'll use postgres or H2 if there isn't anything simpler).
You need one of object databases: http://en.wikipedia.org/wiki/Comparison_of_object_database_management_systems
You should use Terracotta. It is usually used for caching, but its exactly what you are asking for, except that it's "querying" abilities are sparse.
Update:
The previous link was to their "enterprise" edition, but they have the open source project Ehcache which fits your needs, and their enterprise product is based on.

Local message-queue api/library for Java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking for a message-queue api/library for managing queues locally in java. What do you suggest to me?
I don't want to use a Client/Server architecture, I'd rather do it locally to do not add a failure point. Also, scaling out isn't a necessary for now.
[EDITED]
Is there a Message-Queue API/Library for managing queries locally in java?
Features: 1) Persistent Queues; 2) Queue management; 3) Thread-safe
Once upon a time, I looked for persistent queues and could not find good implementation. I think you have 2 options:
use a JMS implementation
use an embedded key-value database with a Map implementation, like JDBM3. Emulate a queue as a Map, where id is assigned at the moment of put as previous max id +1, and take/poll/get reads the value with minimal id.

Is velocity templates good for evaluating conditions? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am thinking about externalizing some conditions instead of implementing them in java so that I can easily change them later as needed.
For example, I need to check if certain keys exist in a given map and if the values of certain keys in a map equal to something.
I was thinking about using spring's expression language, but since we are already using velocity templates, I thought maybe it is a good candidate.
Any idea? Thanks.
You can easily use the #if/#else, #foreach and other condition functionality of velocity to do business logic as part of the velocity template rendering.
However I usually try to separate business logic from rendering in velocity for a number of reasons:
Complexity: The Velocity template can become hard to read, especially
if the target output itself requires complex resulting layout. If you
add additional business logic to the mix, it quickly becomes
impossible to read for anybody else (or for yourself after a few
months of not looking at it constantly)
Testability: It's harder to test Velocity templates, there's
better support for unit/integration testing of Java code
Functionality: Velocity is not a full programming language by
design, so you will miss some things sooner or later and a macro
simply is not a function, e.g. variables by default have global
scope, ... You are bound to run into some of these if you make
your templates big and complex.

Read several html sources from a domain using one connection [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have some problems with a java app i'm developing, i'm using HtmlCleaner 2.2 library (the one used in web-harvest proyect) and have no problem getting the source of a page.
My problem starts when i want to recursively browse the site and get an tree of categories and products as childs. I guess that each time the script visits a page, it counts as a user entering the site, so when it visits 15 or 20 category or product pages, the website firewall blocks my ip for about an hour.
With this problem 2 solutions come to my mind, first: use proxys, i don't get banned and i can download faster using threads, second: open only one connection. I guess it's a bad idea to use proxies so i want to ask, in a simple code, what is the best way to visit recursively about 300000 products of a website without being banned? fastest and simple
Putting the source in a string it's enough to count as visited.
I don't want a debate about the best way, only a well justificated one.
Acclaration: This is a school task, i'm not making any profit of this, and i'm trying to be the less harmful for the site
If your spidering provides legitimate business value to the site your are scraping, you could contact the website owner and ask for either a data feed or an exclusion to their banning algorithm (after all, it's often beneficial for people to have their products exposed to prospective buyers).
UPDATE
Based on your statement that this is a school task, ask your teacher for assistance in finding a website that is willing to be bombarded with traffic in the interest of education, or reach out to the website owner, explain what you are doing, and ask for permission.

Which algorithms are worth to learn or recall on preparation to Java developer interview? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I know that is Collections.sort() method in Java but I think quicksort is worth to remember and try.
My work target is general Java: web, database access, integration, not game developer, scientific application or another one that depends on advanced algorithms.
Which algorithms should I learn to pass without stress Java developer interview?
Fizz Buzz
I usually don't care, if a developer knows the basic algorithms by heart. I do care, if he is capabale of understanding requirements and translating them in correct, testable and understandable pieces of code.
Ah, and I do care if he knows how to implement the most common design patterns. And he should know when and how to use collections, threads and - String#split - it's amazing how many "developers" don't know how to read and process a simple csv file.
Although I fully agree with Joachim comment, I would go for : collection selection. This is not an algorithm per se, but rather a good view of which collection is good for which purpose :
sorted content with constant lookup time ? TreeSet !
mapped data with memorization of insertion order ? LinkedHashMap !
using that, and some knowledge of design patterns behind collections, you will far too often reply to algorithms questions using the knuth answer (or the subtle variation : as long as Sun developpers implemented it correctly, I only have to choose wisely).

Categories

Resources