incubator-cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishan Kavala <Kishan.Kav...@citrix.com>
Subject RE: [1/3] git commit: Add Region APIs
Date Thu, 05 Jul 2012 19:32:03 GMT
Thanks David. I fixed license header.
Also, I added Regions topic branch to avoid disruption in master.

~kishan

> -----Original Message-----
> From: David Nalley [mailto:david@gnsa.us]
> Sent: Thursday, 5 July 2012 12:22 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: Fwd: [1/3] git commit: Add Region APIs
>
> First - nice to see this coming together - I hadn't seen anything since the spec
> was announced back in May.
>
> Second - can you fix the license header in:
> server/src/com/cloud/region/dao/RegionDao.java
> So that it is the appropriate header.
>
> --David
>
>
> ---------- Forwarded message ----------
> From:  <kishan@apache.org>
> Date: Thu, Jul 5, 2012 at 3:13 PM
> Subject: [1/3] git commit: Add Region APIs
> To: cloudstack-commits@incubator.apache.org
>
>
> Updated Branches:
>   refs/heads/regions [created] b5563e832
>
>
> Add Region APIs
>
>
> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
> Commit: http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/commit/b5563e83
> Tree: http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/tree/b5563e83
> Diff: http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/diff/b5563e83
>
> Branch: refs/heads/regions
> Commit: b5563e832e8a7ece7129c5af0c3f9dd1e96301d2
> Parents: 6a1b0f3
> Author: kishan <kishan@cloud.com>
> Authored: Tue Jul 3 13:06:21 2012 -0700
> Committer: kishan <kishan@cloud.com>
> Committed: Tue Jul 3 13:06:21 2012 -0700
>
> ----------------------------------------------------------------------
>  api/src/com/cloud/region/Region.java               |   40 ++++
>  api/src/com/cloud/region/RegionService.java        |   30 +++
>  server/src/com/cloud/region/RegionManager.java     |   30 +++
>  server/src/com/cloud/region/RegionManagerImpl.java |  149
> +++++++++++++++
>  server/src/com/cloud/region/RegionVO.java          |   95 +++++++++
>  server/src/com/cloud/region/dao/RegionDao.java     |   19 ++
>  server/src/com/cloud/region/dao/RegionDaoImpl.java |   33 ++++
>  7 files changed, 396 insertions(+), 0 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/api/src/com/cloud/region/Region.java
> ----------------------------------------------------------------------
> diff --git a/api/src/com/cloud/region/Region.java
> b/api/src/com/cloud/region/Region.java
> new file mode 100644
> index 0000000..5fb8d32
> --- /dev/null
> +++ b/api/src/com/cloud/region/Region.java
> @@ -0,0 +1,40 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region;
> +
> +import java.util.Date;
> +
> +/**
> + *
> + */
> +public interface Region  {
> +    public static enum State {
> +        Up, Down
> +    };
> +
> +    public long getId();
> +
> +       public String getName();
> +
> +       public void setName(String name);
> +
> +       public Region.State getStatus();
> +
> +       public Date getRemoved();
> +
> +       public String getEndPoint();
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/api/src/com/cloud/region/RegionService.java
> ----------------------------------------------------------------------
> diff --git a/api/src/com/cloud/region/RegionService.java
> b/api/src/com/cloud/region/RegionService.java
> new file mode 100644
> index 0000000..e149776
> --- /dev/null
> +++ b/api/src/com/cloud/region/RegionService.java
> @@ -0,0 +1,30 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region;
> +
> +import java.util.List;
> +
> +import com.cloud.api.commands.ListRegionsCmd;
> +import com.cloud.user.Account;
> +
> +
> +public interface RegionService {
> +       public Region addRegion(long id, String name, String endPoint);
> +       public Region updateRegion(long id, String name, String endPoint);
> +       public boolean removeRegion(long id);
> +       public List<? extends Region> listRegions(ListRegionsCmd cmd); }
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/server/src/com/cloud/region/RegionManager.jav
> a
> ----------------------------------------------------------------------
> diff --git a/server/src/com/cloud/region/RegionManager.java
> b/server/src/com/cloud/region/RegionManager.java
> new file mode 100644
> index 0000000..4b61bed
> --- /dev/null
> +++ b/server/src/com/cloud/region/RegionManager.java
> @@ -0,0 +1,30 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region;
> +
> +
> +public interface RegionManager {
> +       public boolean propogateAddResource();
> +       public boolean propogateUpdateResource();
> +       public boolean propogateDeleteResource();
> +       public boolean addResource();
> +       public boolean updateResource();
> +       public boolean deleteResource();
> +
> +       public long getId();
> +       public void setId(long id);
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/server/src/com/cloud/region/RegionManagerIm
> pl.java
> ----------------------------------------------------------------------
> diff --git a/server/src/com/cloud/region/RegionManagerImpl.java
> b/server/src/com/cloud/region/RegionManagerImpl.java
> new file mode 100755
> index 0000000..a440871
> --- /dev/null
> +++ b/server/src/com/cloud/region/RegionManagerImpl.java
> @@ -0,0 +1,149 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +import java.util.Map;
> +
> +import javax.ejb.Local;
> +import javax.naming.ConfigurationException;
> +
> +import org.apache.log4j.Logger;
> +
> +import com.cloud.api.commands.ListRegionsCmd;
> +import com.cloud.exception.InvalidParameterValueException;
> +import com.cloud.region.dao.RegionDao;
> +import com.cloud.utils.component.Inject; import
> +com.cloud.utils.component.Manager;
> +
> +@Local(value = { RegionManager.class, RegionService.class }) public
> +class RegionManagerImpl implements RegionManager,
> RegionService, Manager{
> +    public static final Logger s_logger =
> Logger.getLogger(RegionManagerImpl.class);
> +
> +    @Inject
> +    private RegionDao _regionDao;
> +
> +    private String _name;
> +    private long _id = 1; //ToDo, get this from config
> +
> +    @Override
> +    public boolean configure(final String name, final Map<String,
> Object> params) throws ConfigurationException {
> +        _name = name;
> +        return true;
> +    }
> +
> +    @Override
> +    public boolean start() {
> +        return true;
> +    }
> +
> +    @Override
> +    public boolean stop() {
> +        return true;
> +    }
> +
> +    @Override
> +    public String getName() {
> +        return _name;
> +    }
> +
> +       @Override
> +       public boolean propogateAddResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public boolean propogateUpdateResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public boolean propogateDeleteResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public boolean addResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public boolean updateResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public boolean deleteResource() {
> +               // TODO Auto-generated method stub
> +               return false;
> +       }
> +
> +       @Override
> +       public Region addRegion(long id, String name, String endPoint) {
> +               RegionVO region = new RegionVO(id, name, endPoint);
> +               return _regionDao.persist(region);
> +       }
> +
> +       @Override
> +       public Region updateRegion(long id, String name, String endPoint) {
> +               RegionVO region = _regionDao.findById(id);
> +               if(name != null){
> +                       region.setName(name);
> +               }
> +
> +               if(endPoint != null){
> +                       region.setEndPoint(endPoint);
> +               }
> +
> +               return region;
> +       }
> +
> +       @Override
> +       public boolean removeRegion(long id) {
> +               RegionVO region = _regionDao.findById(id);
> +               if(region != null){
> +                       return _regionDao.remove(id);
> +               } else {
> +                       throw new
> InvalidParameterValueException("Failed to delete Region: " + id + ", Region
> not found");
> +               }
> +       }
> +
> +       public long getId() {
> +               return _id;
> +       }
> +
> +       public void setId(long _id) {
> +               this._id = _id;
> +       }
> +
> +       @Override
> +       public List<RegionVO> listRegions(ListRegionsCmd cmd) {
> +               if(cmd.getId() != null){
> +                       List<RegionVO> regions = new ArrayList<RegionVO>();
> +                       regions.add(_regionDao.findById(cmd.getId()));
> +                       return regions;
> +               }
> +               return _regionDao.listAll();
> +       }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/server/src/com/cloud/region/RegionVO.java
> ----------------------------------------------------------------------
> diff --git a/server/src/com/cloud/region/RegionVO.java
> b/server/src/com/cloud/region/RegionVO.java
> new file mode 100644
> index 0000000..3a3efd5
> --- /dev/null
> +++ b/server/src/com/cloud/region/RegionVO.java
> @@ -0,0 +1,95 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region;
> +
> +import java.util.Date;
> +
> +import javax.persistence.Column;
> +import javax.persistence.Entity;
> +import javax.persistence.EnumType;
> +import javax.persistence.Enumerated;
> +import javax.persistence.Id;
> +import javax.persistence.Table;
> +
> +import com.cloud.region.Region;
> +import com.cloud.utils.db.GenericDao;
> +
> +@Entity
> +@Table(name="region")
> +public class RegionVO implements Region{
> +
> +    @Id
> +    @Column(name="id")
> +    long id;
> +
> +    @Column(name="name")
> +    String name;
> +
> +    @Column(name="end_point")
> +    String endPoint;
> +
> +    @Column(name="status")
> +    @Enumerated(value=EnumType.STRING)
> +    Region.State status;
> +
> +    @Column(name=GenericDao.REMOVED_COLUMN)
> +    private Date removed;
> +
> +    public RegionVO() {
> +    }
> +
> +    public RegionVO(long id, String name, String endPoint) {
> +       this.id = id;
> +       this.name = name;
> +       this.endPoint = endPoint;
> +       this.status = Region.State.Down;
> +    }
> +
> +       public long getId() {
> +               return id;
> +       }
> +
> +       public String getName() {
> +               return name;
> +       }
> +
> +       public void setName(String name) {
> +               this.name = name;
> +       }
> +
> +       public Region.State getStatus() {
> +               return status;
> +       }
> +
> +       public void setStatus(Region.State status) {
> +               this.status = status;
> +       }
> +
> +       public Date getRemoved() {
> +               return removed;
> +       }
> +
> +       public String getEndPoint() {
> +               return endPoint;
> +       }
> +
> +       public void setEndPoint(String endPoint) {
> +               this.endPoint = endPoint;
> +       }
> +
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/server/src/com/cloud/region/dao/RegionDao.jav
> a
> ----------------------------------------------------------------------
> diff --git a/server/src/com/cloud/region/dao/RegionDao.java
> b/server/src/com/cloud/region/dao/RegionDao.java
> new file mode 100644
> index 0000000..a5efc16
> --- /dev/null
> +++ b/server/src/com/cloud/region/dao/RegionDao.java
> @@ -0,0 +1,19 @@
> +// Copyright 2012 Citrix Systems, Inc. Licensed under the // Apache
> +License, Version 2.0 (the "License"); you may not use this // file
> +except in compliance with the License.  Citrix Systems, Inc.
> +// reserves all rights not expressly granted by the License.
> +// You may obtain a copy of the License at
> http://www.apache.org/licenses/LICENSE-2.0
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS, //
> +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +//
> +// Automatically generated by addcopyright.py at 04/03/2012 package
> +com.cloud.region.dao;
> +
> +import com.cloud.region.RegionVO;
> +import com.cloud.utils.db.GenericDao;
> +
> +public interface RegionDao extends GenericDao<RegionVO, Long> { }
>
> http://git-wip-us.apache.org/repos/asf/incubator-
> cloudstack/blob/b5563e83/server/src/com/cloud/region/dao/RegionDaoImp
> l.java
> ----------------------------------------------------------------------
> diff --git a/server/src/com/cloud/region/dao/RegionDaoImpl.java
> b/server/src/com/cloud/region/dao/RegionDaoImpl.java
> new file mode 100644
> index 0000000..79d6d92
> --- /dev/null
> +++ b/server/src/com/cloud/region/dao/RegionDaoImpl.java
> @@ -0,0 +1,33 @@
> +// Licensed to the Apache Software Foundation (ASF) under one // or
> +more contributor license agreements.  See the NOTICE file //
> +distributed with this work for additional information // regarding
> +copyright ownership.  The ASF licenses this file // to you under the
> +Apache License, Version 2.0 (the // "License"); you may not use this
> +file except in compliance // with the License.  You may obtain a copy
> +of the License at //
> +//   http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, //
> +software distributed under the License is distributed on an // "AS IS"
> +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either
> express
> +or implied.  See the License for the // specific language governing
> +permissions and limitations // under the License.
> +package com.cloud.region.dao;
> +
> +import javax.ejb.Local;
> +
> +import org.apache.log4j.Logger;
> +
> +import com.cloud.region.RegionVO;
> +import com.cloud.utils.db.GenericDaoBase;
> +
> +@Local(value={RegionDao.class})
> +public class RegionDaoImpl extends GenericDaoBase<RegionVO, Long>
> implements RegionDao {
> +    private static final Logger s_logger =
> Logger.getLogger(RegionDaoImpl.class);
> +
> +    public RegionDaoImpl(){
> +
> +    }
> +}

Mime
View raw message