Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong synchronization of threads in throttling counting #13

Merged
merged 1 commit into from
Jan 30, 2017

Conversation

openhubframework
Copy link
Collaborator

No description provided.

@hanusto hanusto requested review from hanusto and pjuza January 18, 2017 18:32
Copy link
Collaborator

@hanusto hanusto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my side, it is necessary to do:

  1. read contribution notes - https://openhubframework.atlassian.net/wiki/display/OHF/Contribution
  2. read contribution rules and principles - https://openhubframework.atlassian.net/wiki/display/OHF/Rules+and+principles
  3. for all java based files please change version to 2.0.0 (next release version will be 2.0.0)
  4. please avoid to use full author tag (do not add e-mail address)
  5. it is necessary to rebase these commits on to develop and solve some conflicts
  6. please improve title and description of this PR
  7. it is possible to squash all commits together?

After I can continue in review.

Copy link
Contributor

@pjuza pjuza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add summary of what is going on in this task (https://openhubframework.atlassian.net/browse/OHFJIRA-14) - we know problem and it's necessary to add task description, what is implemented

package org.openhubframework.openhub.common.synchronization;

/**
* Method {@link #doInSynchronizationPart()} in this interface can be synchronized by one one value in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mistake "one one"

import java.util.concurrent.ConcurrentHashMap;

/**
* Executor for {@link SynchronizationBlock} which synchronized more then one threads by one value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which -> that

* Executor for {@link SynchronizationBlock} which synchronized more then one threads by one value.
* <p>
* For synchronization by one value call {@link #execute(SynchronizationBlock, String, Object)}, where in method
* {@link SynchronizationBlock#doInSynchronizationPart()} are code which will be by synchronized by value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which -> that + will be synchronized by value

* Method will be synchronized by one value calling
* {@link SynchronizationExecutor#execute(SynchronizationBlock, String, Object)}.
*/
protected abstract void doInSynchronizationPartNoResult();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the class has name SynchronizationNoResultBlock then method could be shorter, for example doInSynchro or synchroBlock ...

* <p>
* For synchronization by one value call {@link #execute(SynchronizationBlock, String, Object)}, where in method
* {@link SynchronizationBlock#doInSynchronizationPart()} are code which will be by synchronized by value.
* </p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little bit more

:)

@hanusto
Copy link
Collaborator

hanusto commented Jan 19, 2017

@hanusto hanusto changed the title Feature/ohfjira 14 Fixed wrong synchronization threads in counting throttling Jan 19, 2017
@hanusto hanusto changed the title Fixed wrong synchronization threads in counting throttling Fixed wrong synchronization of threads in throttling counting Jan 19, 2017
@hanusto hanusto added the bug label Jan 19, 2017
@hanusto hanusto added this to the v2.0 milestone Jan 19, 2017
Copy link
Collaborator

@hanusto hanusto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes are necessary (reformat code) and consider if lazy loaded singleton is necessary. After clarification it can be approved (merged).

*
* @return instance of this class
*/
public synchronized static SynchronizationExecutor getInstance() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronization of lazy loaded singleton is broken. Please you static eager initialization - http://www.javaworld.com/article/2074979/java-concurrency/double-checked-locking--clever--but-broken.html?page=2.

@@ -45,81 +43,60 @@

private static final int DUMP_PERIOD = 60;

private static final String SYNC_THROTTLING_TYPE = "SYNCHRONIZATION_THROTTLING";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe THROTTLING_SYNCHRONIZATION is better name.


long now = DateTime.now().getMillis();
long from = now - (interval * 1000);
long now = DateTime.now().getMillis();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 70.893% when pulling f65747d774d276a31bace8666e73491127e9d179 on feature/OHFJIRA-14 into 716fd89 on develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 70.893% when pulling b30aaf9 on feature/OHFJIRA-14 into 716fd89 on develop.

@openhubframework openhubframework merged commit 4fdd2b0 into develop Jan 30, 2017
@hanusto hanusto deleted the feature/OHFJIRA-14 branch May 18, 2017 18:55
@openhubframework openhubframework restored the feature/OHFJIRA-14 branch June 13, 2017 19:18
@hanusto hanusto deleted the feature/OHFJIRA-14 branch July 17, 2017 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants