Skip to content

Commit

Permalink
Merge pull request kubeedge#5036 from luomengY/modify-dmi
Browse files Browse the repository at this point in the history
Solving the deployment order dependency of mapper and device
  • Loading branch information
kubeedge-bot authored Sep 22, 2023
2 parents e8de1cc + ea43ef7 commit a22dc13
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions edge/pkg/devicetwin/dtmanager/dmiworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ func (dw *DMIWorker) dealMetaDeviceOperation(context *dtcontext.DTContext, resou
}
switch message.GetOperation() {
case model.InsertOperation:
dw.dmiCache.DeviceMu.Lock()
dw.dmiCache.DeviceList[device.Name] = &device
dw.dmiCache.DeviceMu.Unlock()
err = dmiclient.DMIClientsImp.RegisterDevice(&device)
if err != nil {
klog.Errorf("add device %s failed with err: %v", device.Name, err)
return err
}
dw.dmiCache.DeviceMu.Lock()
dw.dmiCache.DeviceList[device.Name] = &device
dw.dmiCache.DeviceMu.Unlock()
case model.DeleteOperation:
err = dmiclient.DMIClientsImp.RemoveDevice(&device)
if err != nil {
Expand All @@ -140,14 +140,14 @@ func (dw *DMIWorker) dealMetaDeviceOperation(context *dtcontext.DTContext, resou
delete(dw.dmiCache.DeviceList, device.Name)
dw.dmiCache.DeviceMu.Unlock()
case model.UpdateOperation:
dw.dmiCache.DeviceMu.Lock()
dw.dmiCache.DeviceList[device.Name] = &device
dw.dmiCache.DeviceMu.Unlock()
err = dmiclient.DMIClientsImp.UpdateDevice(&device)
if err != nil {
klog.Errorf("udpate device %s failed with err: %v", device.Name, err)
return err
}
dw.dmiCache.DeviceMu.Lock()
dw.dmiCache.DeviceList[device.Name] = &device
dw.dmiCache.DeviceMu.Unlock()
default:
klog.Warningf("unsupported operation %s", message.GetOperation())
}
Expand All @@ -158,14 +158,14 @@ func (dw *DMIWorker) dealMetaDeviceOperation(context *dtcontext.DTContext, resou
}
switch message.GetOperation() {
case model.InsertOperation:
dw.dmiCache.DeviceModelMu.Lock()
dw.dmiCache.DeviceModelList[dm.Name] = &dm
dw.dmiCache.DeviceModelMu.Unlock()
err = dmiclient.DMIClientsImp.CreateDeviceModel(&dm)
if err != nil {
klog.Errorf("add device model %s failed with err: %v", dm.Name, err)
return err
}
dw.dmiCache.DeviceModelMu.Lock()
dw.dmiCache.DeviceModelList[dm.Name] = &dm
dw.dmiCache.DeviceModelMu.Unlock()
case model.DeleteOperation:
err = dmiclient.DMIClientsImp.RemoveDeviceModel(&dm)
if err != nil {
Expand All @@ -176,14 +176,14 @@ func (dw *DMIWorker) dealMetaDeviceOperation(context *dtcontext.DTContext, resou
delete(dw.dmiCache.DeviceModelList, dm.Name)
dw.dmiCache.DeviceModelMu.Unlock()
case model.UpdateOperation:
dw.dmiCache.DeviceModelMu.Lock()
dw.dmiCache.DeviceModelList[dm.Name] = &dm
dw.dmiCache.DeviceModelMu.Unlock()
err = dmiclient.DMIClientsImp.UpdateDeviceModel(&dm)
if err != nil {
klog.Errorf("update device model %s failed with err: %v", dm.Name, err)
return err
}
dw.dmiCache.DeviceModelMu.Lock()
dw.dmiCache.DeviceModelList[dm.Name] = &dm
dw.dmiCache.DeviceModelMu.Unlock()
default:
klog.Warningf("unsupported operation %s", message.GetOperation())
}
Expand Down

0 comments on commit a22dc13

Please sign in to comment.