incubator-hama-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filipe Manana (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HAMA-307) BSPMaster - job ID counter is not read and updated atomically
Date Thu, 14 Oct 2010 00:21:33 GMT

     [ https://issues.apache.org/jira/browse/HAMA-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Filipe Manana updated HAMA-307:
-------------------------------

    Attachment: hama-307.patch

> BSPMaster - job ID counter is not read and updated atomically
> -------------------------------------------------------------
>
>                 Key: HAMA-307
>                 URL: https://issues.apache.org/jira/browse/HAMA-307
>             Project: Hama
>          Issue Type: Bug
>            Reporter: Filipe Manana
>         Attachments: hama-307.patch
>
>
> The nextJobId (int attribute) in BSPMaster is not read and updated atomically, therefore
it's possible that concurrent requests get the same job ID and/or cause the job ID to not
get incremented by the proper quantity.
> The following simple patch fixes it.
> Notice:
> I changed the type from int to Integer.
> This is to avoid doing the following in getNewJobId():
> int id;
> synchronized (this) {
>   id = nextJobId++;
> }
> the instance (referenced by this) is synchronized in many places in BSPMaster, so by
making nextJobId an Integer (object), we can synchronize on it, reducing contention times:
> private Integer nextJobId = Integer.valueOf(1);
> public BSPJobID getNewJobId() throws IOException {
>     int id;
>     synchronized (nextJobId) {
>       id = nextJobId;
>       nextJobId = Integer.valueOf(id + 1);
>     }
>     return new BSPJobID(this.masterIdentifier, id);
>   }
> cheers

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message